org.apache.pdfbox.io

## Class RandomAccessReadWriteBuffer

- java.lang.Object
- - org.apache.pdfbox.io.RandomAccessReadBuffer
  - - org.apache.pdfbox.io.RandomAccessReadWriteBuffer

All Implemented Interfaces:
  Closeable, AutoCloseable, RandomAccess, RandomAccessRead, RandomAccessWrite

    public class RandomAccessReadWriteBuffer
    extends RandomAccessReadBuffer
    implements RandomAccess

An implementation of the RandomAccess interface to store data in memory. The data will be stored in chunks organized in an ArrayList. The data can be read after writing.

### Field Summary

### Fields inherited from class org.apache.pdfbox.io.RandomAccessReadBuffer

`chunkSize, currentBuffer, currentBufferPointer, DEFAULT_CHUNK_SIZE_4KB, pointer, size`

### Constructor Summary

Constructors
Constructor and Description
`RandomAccessReadWriteBuffer()` Default constructor.
`RandomAccessReadWriteBuffer(int definedChunkSize)` Default constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clear()` Clears all data of the buffer.
`void` `write(byte[] b)` Write a buffer of data to the stream.
`void` `write(byte[] b, int off, int len)` Write a buffer of data to the stream.
`void` `write(int b)` Write a byte to the stream.

### Methods inherited from class org.apache.pdfbox.io.RandomAccessReadBuffer

`checkClosed, close, createBufferFromStream, createView, expandBuffer, getPosition, isClosed, isEOF, length, read, read, resetBuffers, seek`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.pdfbox.io.RandomAccessRead

`available, createView, getPosition, isClosed, isEOF, length, peek, read, read, read, readFully, readFully, rewind, seek, skip`

### Methods inherited from interface java.io.Closeable

`close`

### Constructor Detail

#### RandomAccessReadWriteBuffer

    public RandomAccessReadWriteBuffer()

Default constructor.

#### RandomAccessReadWriteBuffer

    public RandomAccessReadWriteBuffer(int definedChunkSize)

Default constructor.

### Method Detail

#### clear

    public void clear()
               throws IOException

Clears all data of the buffer.

Specified by:
  `clear` in interface `RandomAccessWrite`
Throws:
  `IOException` - If there is an error while clearing the data.

#### write

    public void write(int b)
               throws IOException

Write a byte to the stream.

Specified by:
  `write` in interface `RandomAccessWrite`
Parameters:
  `b` - The byte to write.
Throws:
  `IOException` - If there is an IO error while writing.

#### write

    public void write(byte[] b)
               throws IOException

Write a buffer of data to the stream.

Specified by:
  `write` in interface `RandomAccessWrite`
Parameters:
  `b` - The buffer to get the data from.
Throws:
  `IOException` - If there is an error while writing the data.

#### write

    public void write(byte[] b,
                      int off,
                      int len)
               throws IOException

Write a buffer of data to the stream.

Specified by:
  `write` in interface `RandomAccessWrite`
Parameters:
  `b` - The buffer to get the data from.
  `off` - An offset into the buffer to get the data from.
  `len` - The length of data to write.
Throws:
  `IOException` - If there is an error while writing the data.