@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public long write(ByteBuffer[] sources, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(sources.length, offset, length); checkOpenConnected(); int count = FileChannelImpl.calculateTotalRemaining(sources, offset, length, false); if (count == 0) { return 0; } ByteBuffer writeBuf = ByteBuffer.allocate(count); for (int val = offset; val < length + offset; val++) { ByteBuffer source = sources[val]; int oldPosition = source.position(); writeBuf.put(source); source.position(oldPosition); } writeBuf.flip(); int result = writeImpl(writeBuf); int val = offset; int written = result; while (result > 0) { ByteBuffer source = sources[val]; int gap = Math.min(result, source.remaining()); source.position(source.position() + gap); val++; result -= gap; } return written; }
@Override public long read(ByteBuffer[] targets, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(targets.length, offset, length); checkOpenConnected(); int totalCount = FileChannelImpl.calculateTotalRemaining(targets, offset, length, true); if (totalCount == 0) { return 0; } byte[] readArray = new byte[totalCount]; ByteBuffer readBuffer = ByteBuffer.wrap(readArray); int readCount; // read data to readBuffer, and then transfer data from readBuffer to targets. readCount = readImpl(readBuffer); readBuffer.flip(); if (readCount > 0) { int left = readCount; int index = offset; // transfer data from readArray to targets while (left > 0) { int putLength = Math.min(targets[index].remaining(), left); targets[index].put(readArray, readCount - left, putLength); index++; left -= putLength; } } return readCount; }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int write(ByteBuffer src) throws IOException { if (src == null) { throw new NullPointerException("src == null"); } checkOpenConnected(); if (!src.hasRemaining()) { return 0; } return writeImpl(src); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public int read(ByteBuffer dst) throws IOException { dst.checkWritable(); checkOpenConnected(); if (!dst.hasRemaining()) { return 0; } return readImpl(dst); }
@Override public long write(ByteBuffer[] sources, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(sources.length, offset, length); checkOpenConnected(); int count = FileChannelImpl.calculateTotalRemaining(sources, offset, length, false); if (count == 0) { return 0; } ByteBuffer writeBuf = ByteBuffer.allocate(count); for (int val = offset; val < length + offset; val++) { ByteBuffer source = sources[val]; int oldPosition = source.position(); writeBuf.put(source); source.position(oldPosition); } writeBuf.flip(); int result = writeImpl(writeBuf); int val = offset; int written = result; while (result > 0) { ByteBuffer source = sources[val]; int gap = Math.min(result, source.remaining()); source.position(source.position() + gap); val++; result -= gap; } return written; }
@Override public long write(ByteBuffer[] sources, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(sources.length, offset, length); checkOpenConnected(); int count = FileChannelImpl.calculateTotalRemaining(sources, offset, length, false); if (count == 0) { return 0; } ByteBuffer writeBuf = ByteBuffer.allocate(count); for (int val = offset; val < length + offset; val++) { ByteBuffer source = sources[val]; int oldPosition = source.position(); writeBuf.put(source); source.position(oldPosition); } writeBuf.flip(); int result = writeImpl(writeBuf); int val = offset; int written = result; while (result > 0) { ByteBuffer source = sources[val]; int gap = Math.min(result, source.remaining()); source.position(source.position() + gap); val++; result -= gap; } return written; }
@Override public long read(ByteBuffer[] targets, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(targets.length, offset, length); checkOpenConnected(); int totalCount = FileChannelImpl.calculateTotalRemaining(targets, offset, length, true); if (totalCount == 0) { return 0; } byte[] readArray = new byte[totalCount]; ByteBuffer readBuffer = ByteBuffer.wrap(readArray); int readCount; // read data to readBuffer, and then transfer data from readBuffer to targets. readCount = readImpl(readBuffer); readBuffer.flip(); if (readCount > 0) { int left = readCount; int index = offset; // transfer data from readArray to targets while (left > 0) { int putLength = Math.min(targets[index].remaining(), left); targets[index].put(readArray, readCount - left, putLength); index++; left -= putLength; } } return readCount; }
@Override public long read(ByteBuffer[] targets, int offset, int length) throws IOException { Arrays.checkOffsetAndCount(targets.length, offset, length); checkOpenConnected(); int totalCount = FileChannelImpl.calculateTotalRemaining(targets, offset, length, true); if (totalCount == 0) { return 0; } byte[] readArray = new byte[totalCount]; ByteBuffer readBuffer = ByteBuffer.wrap(readArray); int readCount; // read data to readBuffer, and then transfer data from readBuffer to targets. readCount = readImpl(readBuffer); readBuffer.flip(); if (readCount > 0) { int left = readCount; int index = offset; // transfer data from readArray to targets while (left > 0) { int putLength = Math.min(targets[index].remaining(), left); targets[index].put(readArray, readCount - left, putLength); index++; left -= putLength; } } return readCount; }