public static void writeTo(ByteBuffer buffer, File file) throws IOException { FileChannel out = null; try { out = new FileOutputStream(file).getChannel(); out.write(buffer); } finally { closeQuietly(out); } }
public static void writeTo(ByteBuffer buffer, File file) throws IOException { FileChannel out = null; try { out = new FileOutputStream(file).getChannel(); out.write(buffer); } finally { closeQuietly(out); } }
public static ByteBuffer fetchFrom(File file, int length) throws IOException { FileChannel is = null; try { is = new FileInputStream(file).getChannel(); return fetchFrom(is, length); } finally { closeQuietly(is); } }
public static ByteBuffer fetchFrom(File file, int length) throws IOException { FileChannel is = null; try { is = new FileInputStream(file).getChannel(); return fetchFrom(is, length); } finally { closeQuietly(is); } }
public void finish() throws IOException { // Push saved SPS/PPS to a special storage in MP4 outTrack.addSampleEntry(H264Utils.createMOVSampleEntry(spsList, ppsList, 4)); // Write MP4 header and finalize recording muxer.writeHeader(); NIOUtils.closeQuietly(ch); } }
public void readFile(File source, int bufferSize, FileReaderListener listener) throws IOException { ByteBuffer buf = ByteBuffer.allocate(bufferSize); SeekableByteChannel ch = null; try { ch = NIOUtils.readableFileChannel(source); long size = ch.size(); for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) { buf.flip(); data(buf, pos); buf.flip(); if (listener != null) { int newPd = (int) (100 * pos / size); if (newPd != oldPd) listener.progress(newPd); oldPd = newPd; } } } finally { NIOUtils.closeQuietly(ch); } } }
public void readFile(File source, int bufferSize, FileReaderListener listener) throws IOException { ByteBuffer buf = ByteBuffer.allocate(bufferSize); SeekableByteChannel ch = null; try { ch = NIOUtils.readableFileChannel(source); long size = ch.size(); for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) { buf.flip(); data(buf, pos); buf.flip(); if (listener != null) { int newPd = (int) (100 * pos / size); if (newPd != oldPd) listener.progress(newPd); oldPd = newPd; } } } finally { NIOUtils.closeQuietly(ch); } } }