private void ensureAvailable ( final int bytes ) throws IOException { while ( buffer . remaining ( ) < bytes ) { buffer . compact ( ) ; if ( channel . read ( buffer ) < 0 ) { throw new EOFException ( ) ; } buffer . flip ( ) ; } }
Ensures that a certain amount of bytes are in the buffer ready to be read .