public boolean skipTo(long position) throws IOException {
  if (position == position()) {
    return true;
  }
  LogReader skipReader=dlm.getInputStream(position);
  LogRecordWithInputStream logRecord=null;
  try {
    logRecord=nextLogRecord(skipReader);
  }
 catch (  IOException ex) {
    skipReader.close();
    throw ex;
  }
  if (null == logRecord) {
    return false;
  }
  currentPosition=logRecord.getOffset();
  currentLogRecord=logRecord;
  LogReader oldReader=reader;
  reader=skipReader;
  oldReader.close();
  byte[] skipBuffer=new byte[SKIP_BUFFER_SIZE];
  while (currentPosition < position) {
    long bytesToRead=Math.min(position - currentPosition,SKIP_BUFFER_SIZE);
    long bytesRead=read(skipBuffer,0,(int)bytesToRead);
    if (bytesRead < bytesToRead) {
      return false;
    }
  }
  return true;
}

public boolean skipTo ( long position ) throws IOException { if ( position == position ( ) ) { return true ; } LogReader skipReader = dlm . getInputStream ( position ) ; LogRecordWithInputStream logRecord = null ; try { logRecord = nextLogRecord ( skipReader ) ; } catch ( IOException ex ) { skipReader . close ( ) ; throw ex ; } if ( null == logRecord ) { return false ; } currentPosition = logRecord . getOffset ( ) ; currentLogRecord = logRecord ; LogReader oldReader = reader ; reader = skipReader ; oldReader . close ( ) ; byte [ ] skipBuffer = new byte [ SKIP_BUFFER_SIZE ] ; while ( currentPosition < position ) { long bytesToRead = Math . min ( position - currentPosition , SKIP_BUFFER_SIZE ) ; long bytesRead = read ( skipBuffer , 0 , ( int ) bytesToRead ) ; if ( bytesRead < bytesToRead ) { return false ; } } return true ; }
position the reader at the given offset . if we fail to skip to the desired position and don ' t hit end of stream , return false .
