@Override
    public int read(byte[] b, int off, int len) throws IOException {
        fill();
        if (buffered > position) {
            len = Math.min(len, buffered - position);
            System.arraycopy(buffer, position, b, off, len);
            position += len;
            return len;
        } else {
            return -1;
        }
    }
Creates a lookahead wrapper for the given input stream.
The given input stream should support the mark feature,
as otherwise the state of that stream will be undefined
after the lookahead wrapper has been closed. As a special
case a <code>null</code> stream is treated as an empty stream.

@param stream input stream, can be <code>null</code>
@param n      maximum number of bytes to look ahead
tika-core/src/main/java/org/apache/tika/io/LookaheadInputStream.java