Package org.fusesource.hawtbuf
Class ByteArrayOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.fusesource.hawtbuf.ByteArrayOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ByteArrayOutputStream extends java.io.OutputStreamVery 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.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayOutputStream()ByteArrayOutputStream(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckCapacity(int minimumCapacity)Ensures the the buffer has at least the minimumCapacity specified.voidreset()intsize()BuffertoBuffer()byte[]toByteArray()voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(Buffer b)
-
-
-
Method Detail
-
write
public void write(int b)
- Specified by:
writein classjava.io.OutputStream
-
write
public void write(byte[] b, int off, int len)- Overrides:
writein classjava.io.OutputStream
-
write
public void write(Buffer b)
-
checkCapacity
private void checkCapacity(int minimumCapacity)
Ensures the the buffer has at least the minimumCapacity specified.- Parameters:
minimumCapacity-
-
reset
public void reset()
-
toBuffer
public Buffer toBuffer()
-
toByteArray
public byte[] toByteArray()
-
size
public int size()
-
-