private boolean checkBuffer(long offset) throws IOException {
    if (offset - bufferOffset < 0 || offset - bufferOffset >= currentBufferSize) {
      // the given offset is not contained in the buffer
      bufferOffset = offset;
      int index = 0;
      input.seek(offset);
      try {
        //input.read(buffer, 0, maxBufferSize);
        for (long pos = offset; pos < offset + maxBufferSize; pos++) {
          int ch = input.read();
          if (ch > -1) {
            buffer[index] = (byte)ch;
            index++;
          }
        }
      } catch (IOException ex) {
        // not possible
        ex.printStackTrace();
      }
      currentBufferSize = index;
      return true;
    }
    return false;
  }
private boolean checkBuffer ( long offset ) throws IOException { if ( offset - bufferOffset < 0 || offset - bufferOffset >= currentBufferSize ) { bufferOffset = offset ; int index = 0 ; input . seek ( offset ) ; try { for ( long pos = offset ; pos < offset + maxBufferSize ; pos ++ ) { int ch = input . read ( ) ; if ( ch > - 1 ) { buffer [ index ] = ( byte ) ch ; index ++ ; } } } catch ( IOException ex ) { ex . printStackTrace ( ) ; } currentBufferSize = index ; return true ; } return false ; }
Checks if the given offset is already contained in the internal buffer.<br>
If not, fills the buffer starting at the given offset position.

@param offset the offset to check
@throws IOException Signals that an I/O exception has occurred.