Class ResizableByteArrayOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
org.springframework.util.ResizableByteArrayOutputStream
- All Implemented Interfaces:
- Closeable, Flushable, AutoCloseable
An extension of 
ByteArrayOutputStream that:
- has public grow(int)andresize(int)methods to get more control over the size of the internal buffer
- has a higher initial capacity (256) by default
As 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).
- Since:
- 4.0.3
- Author:
- Brian Clozel, Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class ByteArrayOutputStreambuf, count
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newResizableByteArrayOutputStreamwith the default initial capacity of 256 bytes.ResizableByteArrayOutputStream(int initialCapacity) Create a newResizableByteArrayOutputStreamwith the specified initial capacity.
- 
Method SummaryMethods inherited from class ByteArrayOutputStreamclose, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeToMethods inherited from class OutputStreamflush, nullOutputStream, write
- 
Constructor Details- 
ResizableByteArrayOutputStreampublic ResizableByteArrayOutputStream()Create a newResizableByteArrayOutputStreamwith the default initial capacity of 256 bytes.
- 
ResizableByteArrayOutputStreampublic ResizableByteArrayOutputStream(int initialCapacity) Create a newResizableByteArrayOutputStreamwith the specified initial capacity.- Parameters:
- initialCapacity- the initial buffer size in bytes
 
 
- 
- 
Method Details- 
resizepublic void resize(int targetCapacity) Resize the internal buffer size to a specified capacity.- Parameters:
- targetCapacity- the desired size of the buffer
- Throws:
- IllegalArgumentException- if the given capacity is smaller than the actual size of the content stored in the buffer already
- See Also:
 
- 
growpublic void grow(int additionalCapacity) Grow the internal buffer size.- Parameters:
- additionalCapacity- the number of bytes to add to the current buffer size
- See Also:
 
- 
capacitypublic int capacity()Return the current size of this stream's internal buffer.
 
-