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.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.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayOutputStream()
ByteArrayOutputStream(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkCapacity(int minimumCapacity)
Ensures the the buffer has at least the minimumCapacity specified.void
reset()
int
size()
Buffer
toBuffer()
byte[]
toByteArray()
void
write(byte[] b, int off, int len)
void
write(int b)
void
write(Buffer b)
-
-
-
Method Detail
-
write
public void write(int b)
- Specified by:
write
in classjava.io.OutputStream
-
write
public void write(byte[] b, int off, int len)
- Overrides:
write
in 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()
-
-