public static void skip ( InputStream stream , long skip ) throws IOException { long count = skip ; while ( count > 0 ) { count -= stream . skip ( count ) ; } }
The documentation for InputStream . skip indicates that it can bail out early and not skip the requested number of bytes . I ve encountered this in practice hence this helper method .