org.apache.avro.util

## Class NonCopyingByteArrayOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.ByteArrayOutputStream
    - - org.apache.avro.util.NonCopyingByteArrayOutputStream

All Implemented Interfaces:
  Closeable, Flushable, AutoCloseable

    public class NonCopyingByteArrayOutputStream
    extends ByteArrayOutputStream

Utility to make data written to an `ByteArrayOutputStream` directly available as a `ByteBuffer`.

### Field Summary

### Fields inherited from class java.io.ByteArrayOutputStream

`buf, count`

### Constructor Summary

Constructors
Constructor and Description
`NonCopyingByteArrayOutputStream(int size)` Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

### Method Summary

All Methods Instance Methods Concrete Methods
`ByteBuffer` `asByteBuffer()` Get the contents of this ByteArrayOutputStream wrapped as a ByteBuffer.

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

`close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo`

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

`flush, write`

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

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

### Constructor Detail

#### NonCopyingByteArrayOutputStream

    public NonCopyingByteArrayOutputStream(int size)

Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Parameters:
  `size` - the initial size
Throws:
  `IllegalArgumentException` - if size is negative

### Method Detail

#### asByteBuffer

    public ByteBuffer asByteBuffer()

Get the contents of this ByteArrayOutputStream wrapped as a ByteBuffer. This is a shallow copy. Changes to this ByteArrayOutputstream "write through" to the ByteBuffer.

Returns:
  The contents of this ByteArrayOutputstream wrapped as a ByteBuffer