@Override
    public int read() throws IOException
    {
        checkClosed();
        if (pointer >= this.size)
        {
            return -1;
        }
        if (currentBufferPointer >= chunkSize)
        {
            if (bufferListIndex >= bufferListMaxIndex)
            {
                return -1;
            }
            else
            {
                currentBuffer = bufferList.get(++bufferListIndex);
                currentBufferPointer = 0;
            }
        }
        pointer++;
        return currentBuffer.get(currentBufferPointer++) & 0xff;
    }
@Test
    void testPDFBOX5161() throws IOException
    {
        try (RandomAccessRead rar = new RandomAccessReadBuffer(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);
        }
    }