public long skip()

in src/main/java/org/apache/commons/io/input/UnsynchronizedBufferedInputStream.java [403:443]


    public long skip(final long amount) throws IOException {
        // Use local refs since buf and in may be invalidated by an
        // unsynchronized close()
        final byte[] localBuf = buffer;
        final InputStream localIn = inputStream;
        if (localBuf == null) {
            throw new IOException("Stream is closed");
        }
        if (amount < 1) {
            return 0;
        }
        if (localIn == null) {
            throw new IOException("Stream is closed");
        }

        if (count - pos >= amount) {
            // (int count - int pos) here is always an int so amount is also in the int range if the above test is true.
            // We can safely cast to int and avoid static analysis warnings.
            pos += (int) amount;
            return amount;
        }
        int read = count - pos;
        pos = count;

        if (markPos != IOUtils.EOF && amount <= markLimit) {
            if (fillBuffer(localIn, localBuf) == IOUtils.EOF) {
                return read;
            }
            if (count - pos >= amount - read) {
                // (int count - int pos) here is always an int so (amount - read) is also in the int range if the above test is true.
                // We can safely cast to int and avoid static analysis warnings.
                pos += (int) amount - read;
                return amount;
            }
            // Couldn't get all the bytes, skip what we read
            read += count - pos;
            pos = count;
            return read;
        }
        return read + localIn.skip(amount - read);
    }