public void load(){
  try {
    if (fileChannel == null) {
      fileChannel=FileChannel.open(path,StandardOpenOption.READ);
    }
    fileChannel.position(0L);
    buffer.clear();
    tmp.clear();
    while (fileChannel.read(tmp) > 0) {
      tmp.flip();
      if (tmp.remaining() > buffer.capacity() - buffer.position()) {
        final ByteBuffer next=ByteBuffer.allocateDirect(Math.max(buffer.capacity() * 2,tmp.remaining()));
        buffer.flip();
        next.put(buffer);
        buffer=next;
      }
      buffer.put(tmp);
      tmp.clear();
    }
    buffer.flip();
  }
 catch (  final IOException e) {
    throw new UncheckedIOException(e);
  }
}

public void load ( ) { try { if ( fileChannel == null ) { fileChannel = FileChannel . open ( path , StandardOpenOption . READ ) ; } fileChannel . position ( 0L ) ; buffer . clear ( ) ; tmp . clear ( ) ; while ( fileChannel . read ( tmp ) > 0 ) { tmp . flip ( ) ; if ( tmp . remaining ( ) > buffer . capacity ( ) - buffer . position ( ) ) { final ByteBuffer next = ByteBuffer . allocateDirect ( Math . max ( buffer . capacity ( ) * 2 , tmp . remaining ( ) ) ) ; buffer . flip ( ) ; next . put ( buffer ) ; buffer = next ; } buffer . put ( tmp ) ; tmp . clear ( ) ; } buffer . flip ( ) ; } catch ( final IOException e ) { throw new UncheckedIOException ( e ) ; } }
opens a channel to the specified path if it does not already exist . allocates a larger bytebuffer if file size & gt ; current buffer size . reads file data into bytebuffer .
