org.jppf.utils.streams
Class JPPFByteArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by org.jppf.utils.streams.JPPFByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class JPPFByteArrayOutputStream
extends ByteArrayOutputStream

Extension of ByteArrayOutputStream, providing a faster toByteArray() method that does not involve copying its internal buffer.

Author:
Laurent Cohen

Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
JPPFByteArrayOutputStream()
          Instantiate this stream with a default size.
JPPFByteArrayOutputStream(int size)
          Instantiate this stream with the specified size.
 
Method Summary
 byte[] getBuf()
          Provide access to the internal buffer.
 byte[] toByteArray()
          Override of toByteArray() that returns a reference to the internal buffer instead of copy of it, significantly increasing the performance of this operation.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, 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

JPPFByteArrayOutputStream

public JPPFByteArrayOutputStream()
Instantiate this stream with a default size.


JPPFByteArrayOutputStream

public JPPFByteArrayOutputStream(int size)
Instantiate this stream with the specified size.

Parameters:
size - the initial size of the underlying buffer.
Method Detail

toByteArray

public byte[] toByteArray()
Override of toByteArray() that returns a reference to the internal buffer instead of copy of it, significantly increasing the performance of this operation.

Overrides:
toByteArray in class ByteArrayOutputStream
Returns:
the content of the stream as an array of bytes.
See Also:
ByteArrayOutputStream.toByteArray()

getBuf

public byte[] getBuf()
Provide access to the internal buffer.

Returns:
an array of bytes.


Copyright © 2005-2010 JPPF Team.