public class ResizableByteArrayOutputStream
extends java.io.ByteArrayOutputStream
ByteArrayOutputStream
that:
grow(int)
and resize(int)
methods
to get more control over the size of the internal bufferAs of 4.2, this class has been superseded by FastByteArrayOutputStream
for Spring's internal use where no assignability to ByteArrayOutputStream
is needed (since FastByteArrayOutputStream
is more efficient with buffer
resize management but doesn't extend the standard ByteArrayOutputStream
).
resize(int)
,
FastByteArrayOutputStream
Constructor and Description |
---|
ResizableByteArrayOutputStream()
Create a new
ResizableByteArrayOutputStream
with the default initial capacity of 256 bytes. |
ResizableByteArrayOutputStream(int initialCapacity)
Create a new
ResizableByteArrayOutputStream
with the specified initial capacity. |
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Return the current size of this stream's internal buffer.
|
void |
grow(int additionalCapacity)
Grow the internal buffer size.
|
void |
resize(int targetCapacity)
Resize the internal buffer size to a specified capacity.
|
public ResizableByteArrayOutputStream()
ResizableByteArrayOutputStream
with the default initial capacity of 256 bytes.public ResizableByteArrayOutputStream(int initialCapacity)
ResizableByteArrayOutputStream
with the specified initial capacity.initialCapacity
- the initial buffer size in bytespublic void resize(int targetCapacity)
targetCapacity
- the desired size of the bufferjava.lang.IllegalArgumentException
- if the given capacity is smaller than
the actual size of the content stored in the buffer alreadyByteArrayOutputStream.size()
public void grow(int additionalCapacity)
additionalCapacity
- the number of bytes to add to the current buffer sizeByteArrayOutputStream.size()
public int capacity()