@Override
    public void write(int b) throws IOException
    {
        checkClosed();

        if (chunkSize - currentBufferPointer <= 0)
        {
            expandBuffer();
        }
        currentBuffer.put((byte) b);
        currentBufferPointer++;
        pointer++;
        if (pointer > size)
        {
            size = pointer;
        }
    }
@Test
    void testRandomAccessRead() throws IOException
    {
        try (RandomAccess randomAccessReadWrite = new RandomAccessReadWriteBuffer())
        {
            randomAccessReadWrite.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
            assertEquals(11, randomAccessReadWrite.length());
            randomAccessReadWrite.seek(0);
            assertEquals(11, randomAccessReadWrite.length());
            byte[] bytesRead = new byte[11];
            assertEquals(11, randomAccessReadWrite.read(bytesRead));
            assertEquals(1, bytesRead[0]);
            assertEquals(7, bytesRead[6]);
            assertEquals(8, bytesRead[7]);
            assertEquals(11, bytesRead[10]);
        }
        catch (Throwable throwable)
        {
            fail("Unexpected exception " + throwable.getMessage());
        }
    }