List of utility methods to do FileChannel Read
ByteBuffer | readFully(FileChannel channel, ByteBuffer buffer) read Fully int read = 0; while (buffer.hasRemaining() && read != -1) { read = channel.read(buffer); if (buffer.hasRemaining()) { throw new BufferUnderflowException(); buffer.flip(); ... |
void | readFully(FileChannel channel, ByteBuffer buffer, long ptr) Reads as much as possible from the channel into the buffer. while (buffer.remaining() > 0) { long read = channel.read(buffer, ptr); if (read == -1) { throw new EOFException(); } else { ptr += read; |
void | readFully(FileChannel channel, ByteBuffer dst) Fully read from the file. do { int r = channel.read(dst); if (r < 0) { throw new EOFException(); } while (dst.remaining() > 0); |
void | readFully(FileChannel channel, long offset, ByteBuffer buf) read Fully int remaining = buf.limit() - buf.position(); while (remaining > 0) { int read = channel.read(buf, offset); if (read < 0) throw new EOFException(); remaining -= read; |
void | readFully(FileChannel fileChannel, long filePosition, ByteBuffer buffer) read Fully int startBufferPosition = buffer.position(); while (buffer.remaining() > 0 && buffer.position() < fileChannel.size()) { int bytesRead = fileChannel.read(buffer, filePosition + buffer.position() - startBufferPosition); if (bytesRead == -1) break; |