public static void readFully(FileChannel file,long pos,ByteBuffer dst){
  try {
    do {
      int len=file.read(dst,pos);
      if (len < 0) {
        throw new EOFException();
      }
      pos+=len;
    }
 while (dst.remaining() > 0);
    dst.rewind();
  }
 catch (  IOException e) {
    long size;
    try {
      size=file.size();
    }
 catch (    IOException e2) {
      size=-1;
    }
    throw newIllegalStateException(ERROR_READING_FAILED,"Reading from {0} failed; file length {1} " + "read length {2} at {3}",file,size,dst.remaining(),pos,e);
  }
}

public static void readFully ( FileChannel file , long pos , ByteBuffer dst ) { try { do { int len = file . read ( dst , pos ) ; if ( len < 0 ) { throw new EOFException ( ) ; } pos += len ; } while ( dst . remaining ( ) > 0 ) ; dst . rewind ( ) ; } catch ( IOException e ) { long size ; try { size = file . size ( ) ; } catch ( IOException e2 ) { size = - 1 ; } throw newIllegalStateException ( ERROR_READING_FAILED , "Reading from {0} failed; file length {1} " + "read length {2} at {3}" , file , size , dst . remaining ( ) , pos , e ) ; } }
read from a file channel until the buffer is full . the buffer is rewind after reading .
