public static long skip ( final InputStream input , final long toSkip ) throws UncheckedIOException { if ( toSkip < 0 ) { throw new IllegalArgumentException ( "Skip count must be non-negative, actual: " + toSkip ) ; } else if ( toSkip == 0 ) { return 0 ; } final byte [ ] buf = Objectory . createByteArrayBuffer ( ) ; long remain = toSkip ; try { while ( remain > 0 ) { long n = read ( input , buf , 0 , ( int ) Math . min ( remain , buf . length ) ) ; if ( n < 0 ) { // EOF break ; } remain -= n ; } return toSkip - remain ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } finally { Objectory . recycle ( buf ) ; } }
Return the count of skipped bytes .