LoadingByteArrayOutputStream (Apache CXF JavaDoc 4.1.0-SNAPSHOT API)
Description: declaration: package: org.apache.cxf.helpers, class: LoadingByteArrayOutputStream

Package org.apache.cxf.helpers

# Class LoadingByteArrayOutputStream

java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
org.apache.cxf.helpers.LoadingByteArrayOutputStream

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

public class LoadingByteArrayOutputStream extends ByteArrayOutputStream
Subclass of ByteArrayOutputStream that allows creation of a ByteArrayInputStream directly without creating a copy of the byte[]. Also, on "toByteArray()" it truncates it's buffer to the current size and returns the new buffer directly. Multiple calls to toByteArray() will return the exact same byte[] unless a write is called in between. Note: once the InputStream is created, the output stream should no longer be used. In particular, make sure not to call reset() and then write as that may overwrite the data that the InputStream is using.

- ## Field Summary

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

  `buf, count`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LoadingByteArrayOutputStream()`
  `LoadingByteArrayOutputStream(int i)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ByteArrayInputStream`
  `createInputStream()`
  `byte[]`
  `getRawBytes()`
  `void`
  `setSize(int i)`
  `byte[]`
  `toByteArray()`

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

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

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

  `flush, nullOutputStream, write`

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

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

- ## Constructor Details

  - ### LoadingByteArrayOutputStream

    public LoadingByteArrayOutputStream()

  - ### LoadingByteArrayOutputStream

    public LoadingByteArrayOutputStream(int i)

- ## Method Details

  - ### createInputStream

    public ByteArrayInputStream createInputStream()

  - ### setSize

    public void setSize(int i)

  - ### toByteArray

    public byte[] toByteArray()
    Overrides:
      `toByteArray` in class `ByteArrayOutputStream`

  - ### getRawBytes

    public byte[] getRawBytes()