Class LoadingByteArrayOutputStream

  extended by
      extended by
          extended by org.apache.camel.component.http.helper.LoadingByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable

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
buf, count
Constructor Summary
LoadingByteArrayOutputStream(int size)
Method Summary
 ByteArrayInputStream createInputStream()
 byte[] toByteArray()
Methods inherited from class
close, reset, size, toString, toString, toString, write, write, writeTo
Methods inherited from class
flush, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public LoadingByteArrayOutputStream()


public LoadingByteArrayOutputStream(int size)
Method Detail


public ByteArrayInputStream createInputStream()


public byte[] toByteArray()
toByteArray in class ByteArrayOutputStream

Copyright © 2007-2010 IONA Open Source Community. All Rights Reserved.