@Override
    public int read() throws IOException
    {
        checkClosed();
        if (isEOF())
        {
            return -1;
        }
        if (currentBufferPointer >= bufferBytes[CURRENT] && !fetch())
        {
            isEOF = true;
            return -1;
        }
        position++;
        return buffers[CURRENT][currentBufferPointer++] & 0xFF;
    }
@Test
    void testPDFBOX5161() throws IOException
    {
        try (RandomAccessRead rar = new NonSeekableRandomAccessReadInputStream(
                new ByteArrayInputStream(new byte[4099])))
        {
            byte[] buf = new byte[4096];
            int bytesRead = rar.read(buf);
            assertEquals(4096, bytesRead);
            bytesRead = rar.read(buf, 0, 3);
            assertEquals(3, bytesRead);
        }
    }