Package org.apache.avro.util

# Class ByteBufferOutputStream

java.lang.Object
java.io.OutputStream
org.apache.avro.util.ByteBufferOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

public class ByteBufferOutputStream extends OutputStream
Utility to collect data written to an `OutputStream` in `ByteBuffer`s.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BUFFER_SIZE`

## Constructor Summary

Constructors
Constructor
Description
`ByteBufferOutputStream()`

## Method Summary

Modifier and Type
Method
Description
`void`
`append(List<ByteBuffer> lists)`
Append a list of ByteBuffers to this stream.
`List<ByteBuffer>`
`getBufferList()`
Returns all data written and resets the stream to be empty.
`void`
`prepend(List<ByteBuffer> lists)`
Prepend a list of ByteBuffers to this stream.
`void`
`reset()`
`void`
`write(byte[] b, int off, int len)`
`void`
`write(int b)`
`void`
`write(ByteBuffer buffer)`
`void`
`writeBuffer(ByteBuffer buffer)`
Add a buffer to the output without copying, if possible.

### Methods inherited from class java.io.OutputStream

`close, flush, nullOutputStream, write`

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

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

## Field Details

### BUFFER_SIZE

public static final int BUFFER_SIZE

See Also:
  - Constant Field Values

## Constructor Details

### ByteBufferOutputStream

public ByteBufferOutputStream()

## Method Details

### getBufferList

public List<ByteBuffer> getBufferList()
Returns all data written and resets the stream to be empty.

### prepend

public void prepend(List<ByteBuffer> lists)
Prepend a list of ByteBuffers to this stream.

### append

public void append(List<ByteBuffer> lists)
Append a list of ByteBuffers to this stream.

### reset

public void reset()

### write

public void write(ByteBuffer buffer)

### write

public void write(int b)

Specified by:
  `write` in class `OutputStream`

### write

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

Overrides:
  `write` in class `OutputStream`

### writeBuffer

public void writeBuffer(ByteBuffer buffer) throws IOException
Add a buffer to the output without copying, if possible.

Throws:
  `IOException`