org.activemq.io.util
Class WireByteArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by org.activemq.io.util.WireByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class WireByteArrayOutputStream
extends ByteArrayOutputStream

Optimized ByteArrayOutputStream

Version:
$Revision: 1.1.1.1 $

Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
WireByteArrayOutputStream()
          Creates a new byte array output stream.
WireByteArrayOutputStream(int size)
          Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
 
Method Summary
 byte[] getData()
           
 void reset()
          reset the output stream
 void restart()
          start using a fresh byte array
 void restart(int size)
          start using a fresh byte array
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
 void write(int b)
          Writes the specified byte to this byte array output stream.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, size, toByteArray, toString, toString, toString, 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

WireByteArrayOutputStream

public WireByteArrayOutputStream()
Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary.


WireByteArrayOutputStream

public WireByteArrayOutputStream(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

restart

public void restart(int size)
start using a fresh byte array

Parameters:
size -

restart

public void restart()
start using a fresh byte array


write

public void write(int b)
Writes the specified byte to this byte array output stream.

Overrides:
write in class ByteArrayOutputStream
Parameters:
b - the byte to be written.

write

public void write(byte[] b,
                  int off,
                  int len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.

Overrides:
write in class ByteArrayOutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.

getData

public byte[] getData()
Returns:
the underlying byte[] buffer

reset

public void reset()
reset the output stream

Overrides:
reset in class ByteArrayOutputStream


Copyright © 2004-2010 Protique, Ltd.. All Rights Reserved.