org.apache.activemq.protobuf
Class BufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.activemq.protobuf.BufferOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public final class BufferOutputStream
extends java.io.OutputStream

Very similar to the java.io.ByteArrayOutputStream but this version is not thread safe and the resulting data is returned in a Buffer to avoid an extra byte[] allocation. It also does not re-grow it's internal buffer.


Constructor Summary
BufferOutputStream(Buffer data)
           
BufferOutputStream(byte[] buffer)
           
BufferOutputStream(int size)
           
 
Method Summary
 Buffer getNextBuffer(int len)
           
 void reset()
           
 int size()
           
 Buffer toBuffer()
           
 byte[] toByteArray()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferOutputStream

public BufferOutputStream(int size)

BufferOutputStream

public BufferOutputStream(byte[] buffer)

BufferOutputStream

public BufferOutputStream(Buffer data)
Method Detail

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

getNextBuffer

public Buffer getNextBuffer(int len)
                     throws java.io.IOException
Throws:
java.io.IOException

reset

public void reset()

toBuffer

public Buffer toBuffer()

toByteArray

public byte[] toByteArray()

size

public int size()


Copyright © 2011 Apache Software Foundation. All Rights Reserved.