private boolean fastForward ( ) throws IOException { try { boolean stillTruncate ; buffer . clear ( ) ; if ( channel . read ( buffer ) > - 1 || isEof ( ) ) { //set the buffer into read from mode buffer . flip ( ) ; //we have data, lets look for the first EOL in it. int firstEolIdx = findEndOfFirstLine ( buffer ) ; if ( firstEolIdx > - 1 ) { // set position to position after first EOL buffer . position ( firstEolIdx + 1 ) ; // set the buffer back into write into mode keeping data after first EOL buffer . compact ( ) ; stillTruncate = false ; offset = channel . position ( ) - buffer . position ( ) ; } else { // no EOL yet // whatever was read will be discarded on next next() call stillTruncate = true ; offset = channel . position ( ) ; } } else { // no data read // whatever was read will be discarded on next next() call stillTruncate = true ; offset = channel . position ( ) ; } return stillTruncate ; } catch ( IOException ex ) { closeChannel ( ) ; throw ex ; } }
returns true if still in truncate mode false otherwise