public class ConservativeSizingByteArrayOutputStream
extends java.io.OutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected int |
count |
| Constructor and Description |
|---|
ConservativeSizingByteArrayOutputStream(byte[] buffer)
Creates a new byte array output stream, with the given initial
buffer
|
ConservativeSizingByteArrayOutputStream(int capacity)
Creates a new byte array output stream, with the given initial
buffer capacity
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
allocateByteArray(int size) |
byte[] |
relinquishByteArray()
Allows the caller to take ownership of this output stream's
byte array.
|
void |
reset() |
protected void |
resizeArrayToFit(int newCount) |
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
boolean |
trim() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public ConservativeSizingByteArrayOutputStream(int capacity)
capacity - The initial capacityjava.lang.IllegalArgumentException - if capacity is negativepublic ConservativeSizingByteArrayOutputStream(byte[] buffer)
buffer - The initial bufferjava.lang.IllegalArgumentException - if capacity is negativepublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void reset()
public byte[] toByteArray()
public int size()
public byte[] relinquishByteArray()
public boolean trim()
protected void resizeArrayToFit(int newCount)
protected byte[] allocateByteArray(int size)