public class PoolingByteArrayOutputStream
extends java.io.ByteArrayOutputStream
ByteArrayOutputStream
that uses a pool of byte[] buffers instead
of always allocating them fresh, saving on heap churn.Constructor and Description |
---|
PoolingByteArrayOutputStream(ByteArrayPool pool)
Constructs a new PoolingByteArrayOutputStream with a default size.
|
PoolingByteArrayOutputStream(ByteArrayPool pool,
int size)
Constructs a new
ByteArrayOutputStream with a default size of size bytes. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
finalize() |
void |
write(byte[] buffer,
int offset,
int len) |
void |
write(int oneByte) |
public PoolingByteArrayOutputStream(ByteArrayPool pool)
public PoolingByteArrayOutputStream(ByteArrayPool pool, int size)
ByteArrayOutputStream
with a default size of size
bytes. If
more than size
bytes are written to this instance, the underlying byte array will
expand.size
- initial size for the underlying byte array. The value will be pinned to a default
minimum size.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.ByteArrayOutputStream
java.io.IOException
public void finalize()
finalize
in class java.lang.Object
public void write(byte[] buffer, int offset, int len)
write
in class java.io.ByteArrayOutputStream
public void write(int oneByte)
write
in class java.io.ByteArrayOutputStream