Top Description Fields Constructors Methods
org.springframework.util

public Class ResizableByteArrayOutputStream

extends ByteArrayOutputStream
Class Inheritance
Imports
java.io.ByteArrayOutputStream

An extension of java.io.ByteArrayOutputStream that:

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).

Authors
Brian Clozel, Juergen Hoeller
Since
4.0.3
See Also
resize, FastByteArrayOutputStream

Field Summary

Modifier and TypeField and Description
private static final int
Inherited from java.io.ByteArrayOutputStream:
bufcount

Constructor Summary

AccessConstructor and Description
public
ResizableByteArrayOutputStream()

Create a new ResizableByteArrayOutputStream with the default initial capacity of 256 bytes.

public
ResizableByteArrayOutputStream(int
the initial buffer size in bytes
initialCapacity
)

Create a new ResizableByteArrayOutputStream with the specified initial capacity.

Method Summary

Modifier and TypeMethod and Description
public synchronized int
capacity()

Return the current size of this stream's internal buffer.

public synchronized void
grow(int
the number of bytes to add to the current buffer size
additionalCapacity
)

Grow the internal buffer size.

public synchronized void
resize(int
the desired size of the buffer
targetCapacity
)

Resize the internal buffer size to a specified capacity.

Inherited from java.io.ByteArrayOutputStream:
closeresetsizetoByteArraytoStringtoStringtoStringtoStringwritewritewriteByteswriteTo

Field Detail

DEFAULT_INITIAL_CAPACITYback to summary
private static final int DEFAULT_INITIAL_CAPACITY

Constructor Detail

ResizableByteArrayOutputStreamback to summary
public ResizableByteArrayOutputStream()

Create a new ResizableByteArrayOutputStream with the default initial capacity of 256 bytes.

ResizableByteArrayOutputStreamback to summary
public ResizableByteArrayOutputStream(int initialCapacity)

Create a new ResizableByteArrayOutputStream with the specified initial capacity.

Parameters
initialCapacity:int

the initial buffer size in bytes

Method Detail

capacityback to summary
public synchronized int capacity()

Return the current size of this stream's internal buffer.

growback to summary
public synchronized void grow(int additionalCapacity)

Grow the internal buffer size.

Parameters
additionalCapacity:int

the number of bytes to add to the current buffer size

See Also
ResizableByteArrayOutputStream#size()
resizeback to summary
public synchronized void resize(int targetCapacity)

Resize the internal buffer size to a specified capacity.

Parameters
targetCapacity:int

the desired size of the buffer

Exceptions
IllegalArgumentException:
if the given capacity is smaller than the actual size of the content stored in the buffer already
See Also
ResizableByteArrayOutputStream#size()