private boolean seekOrSkip ( long bytes , boolean toNewSource ) throws IOException { if ( seekableIn != null ) { // Use Seekable interface to speed up skip. int available = in . available ( ) ; try { if ( toNewSource ) { return seekableIn . seekToNewSource ( seekableIn . getPos ( ) + bytes ) ; } else { seekableIn . seek ( seekableIn . getPos ( ) + bytes ) ; return true ; } } catch ( IOException e ) { if ( bytes > available && "Cannot seek after EOF" . equals ( e . getMessage ( ) ) ) { eofReached = true ; throw new EOFException ( e . getMessage ( ) ) ; } } } else { // Do raw skip. long toSkip = bytes ; while ( toSkip > 0 ) { long skipped = in . skip ( toSkip ) ; if ( skipped <= 0 ) { throw new EOFException ( "skip returned " + skipped ) ; } toSkip -= skipped ; } ; } return true ; }
This function depends on the underlying