List of utility methods to do ReadableByteChannel Copy
void | copy(ReadableByteChannel _in, WritableByteChannel out, long amount) copy ByteBuffer buf = ByteBuffer.allocate(0x10000); int read; do { buf.position(0); buf.limit((int) Math.min(amount, buf.capacity())); read = _in.read(buf); if (read != -1) { buf.flip(); ... |
void | copy(ReadableByteChannel input, WritableByteChannel output, long start, long length) Copy the given byte range of the given input to the given output. if (input instanceof FileChannel) { ((FileChannel) input).transferTo(start, length, output); } else if (input instanceof SeekableByteChannel) { ((SeekableByteChannel) input).position(start); fastChannelCopy(input, output, length); } else { skip(input, start); fastChannelCopy(input, output, length); ... |
int | copy(ReadableByteChannel inputChannel, WritableByteChannel outputChannel) copy ByteBuffer buffer = ByteBuffer.allocateDirect(128); int readSize = 0; int copySize = 0; while (true) { readSize = inputChannel.read(buffer); if (readSize == -1) break; copySize += readSize; ... |
void | copy(ReadableByteChannel source, WritableByteChannel destination) Copy the source to target chanel vio java nio. final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024); while (source.read(buffer) != -1) { buffer.flip(); destination.write(buffer); buffer.compact(); buffer.flip(); while (buffer.hasRemaining()) { ... |
void | copy(ReadableByteChannel src, WritableByteChannel dest) Helper method to copy from a readable channel to a writable channel, using an in-memory buffer. ByteBuffer buffer = ByteBuffer.allocate(8092); while (src.read(buffer) != -1) { buffer.flip(); while (buffer.hasRemaining()) { dest.write(buffer); buffer.clear(); |
long | copyTo(ReadableByteChannel from, WritableByteChannel to) Copies all bytes from the readable channel to the writable channel. return copyTo(from, to, false);
|
void | fastChannelCopy(final ReadableByteChannel input, final WritableByteChannel output, long toRead) fast Channel Copy final ByteBuffer buffer = ByteBuffer.allocateDirect(DEFAULT_BUFFER_SIZE); int read; while (toRead > 0) { read = input.read(buffer); if (read > 0) { buffer.flip(); if (toRead < read) { buffer.limit((int) toRead); ... |
void | fastChannelCopy(final ReadableByteChannel src, final WritableByteChannel dest) Performs a fast channel copy from src to dest . final ByteBuffer buffer = ByteBuffer.allocateDirect(4 * BUFFER_SIZE); while (src.read(buffer) != -1) { buffer.flip(); dest.write(buffer); buffer.compact(); buffer.flip(); while (buffer.hasRemaining()) { ... |
void | fastChannelCopy(final ReadableByteChannel src, final WritableByteChannel dest) Copies a ReadableByteChannel into a WritableByteChannel byte channel.
final ByteBuffer buffer = ByteBuffer.allocateDirect(DEFAULT_BUFFER_SIZE); try { while (src.read(buffer) != -1) { buffer.flip(); dest.write(buffer); buffer.compact(); buffer.flip(); ... |
void | fastChannelCopy(ReadableByteChannel src, WritableByteChannel dest) fast Channel Copy ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024); while (src.read(buffer) != -1) { buffer.flip(); dest.write(buffer); buffer.compact(); buffer.flip(); while (buffer.hasRemaining()) { ... |