Java Utililty Methods ReadableByteChannel Copy

List of utility methods to do ReadableByteChannel Copy

Description

The list of methods to do ReadableByteChannel Copy are organized into topic(s).

Method

voidcopy(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();
...
voidcopy(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);
...
intcopy(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;
...
voidcopy(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()) {
...
voidcopy(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();
longcopyTo(ReadableByteChannel from, WritableByteChannel to)
Copies all bytes from the readable channel to the writable channel.
return copyTo(from, to, false);
voidfastChannelCopy(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);
...
voidfastChannelCopy(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()) {
...
voidfastChannelCopy(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();
...
voidfastChannelCopy(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()) {
...