aliocrlib/src/main/java/com/lib/aliocr/utils/io/IOUtils.java
/**
     * Skip characters from an input character stream.
     * This implementation guarantees that it will read as many characters
     * as possible before giving up; this may not always be the case for
     * subclasses of {@link Reader}.
     *
     * @param input  character stream to skip
     * @param toSkip number of characters to skip.
     * @return number of characters actually skipped.
     * @throws IOException              if there is a problem reading the file
     * @throws IllegalArgumentException if toSkip is negative
     * @see Reader#skip(long)
     * @since 2.0
     */
Skip characters from an input character stream.
This implementation guarantees that it will read as many characters
as possible before giving up; this may not always be the case for
subclasses of  Reader.

@param input  character stream to skip
@param toSkip number of characters to skip.
@return number of characters actually skipped.
@throws IOException              if there is a problem reading the file
@throws IllegalArgumentException if toSkip is negative
@see Reader#skip(long)
@since 2.0
Skip characters from an input character stream . This implementation guarantees that it will read as many characters as possible before giving up ; this may not always be the case for subclasses of Reader . @param input character stream to skip @param toSkip number of characters to skip . @return number of characters actually skipped . @throws IOException if there is a problem reading the file @throws IllegalArgumentException if toSkip is negative @see Reader#skip ( long ) @since 2 . 0
public static long skip(Reader input, long toSkip) throws IOException {
        if (toSkip < 0) {
            throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip);
        }
        /*
         * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data
         * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer
         * size were variable, we would need to sync. to ensure some other thread did not create a smaller one)
         */
        if (SKIP_CHAR_BUFFER == null) {
            SKIP_CHAR_BUFFER = new char[SKIP_BUFFER_SIZE];
        }
        long remain = toSkip;
        while (remain > 0) {
            long n = input.read(SKIP_CHAR_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE));
            if (n < 0) { 
                break;
            }
            remain -= n;
        }
        return toSkip - remain;
    }
public static long skip ( Reader input , long toSkip ) throws IOException { if ( toSkip < 0 ) { throw new IllegalArgumentException ( "Skip count must be non-negative, actual: " + toSkip ) ; } /*
         * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data
         * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer
         * size were variable, we would need to sync. to ensure some other thread did not create a smaller one)
         */ if ( SKIP_CHAR_BUFFER == null ) { SKIP_CHAR_BUFFER = new char [ SKIP_BUFFER_SIZE ] ; } long remain = toSkip ; while ( remain > 0 ) { long n = input . read ( SKIP_CHAR_BUFFER , 0 , ( int ) Math . min ( remain , SKIP_BUFFER_SIZE ) ) ; if ( n < 0 ) { break ; } remain -= n ; } return toSkip - remain ; }
Skip characters from an input character stream.
Skip characters from an input character stream .
// EOF