Here you can find the source of readFully(FileChannel channel, long offset, ByteBuffer buf)
static void readFully(FileChannel channel, long offset, ByteBuffer buf) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.*; import java.nio.channels.FileChannel; public class Main { static void readFully(FileChannel channel, long offset, ByteBuffer buf) throws IOException { int remaining = buf.limit() - buf.position(); while (remaining > 0) { int read = channel.read(buf, offset); if (read < 0) throw new EOFException(); remaining -= read;/*from w w w . j a va 2 s. c o m*/ } } }