Accumulates output in a byte array that automatically grows as needed.
Data is retrieved using toByteArray(), toByteArrayInputStream(), toString() and toString(encoding).
{@link #close() Closing} a ClosableByteArrayOutputStream preventsfurther write operations, but all other operations may succeed until after the first invocation of {@link #free() free()}.
Freeing a ClosableByteArrayOutputStream closes the stream and releases the internal buffer, preventing successful invocation of all operations, with the exception of size(), close(), isClosed(), free() and isFreed().
This class is especially useful when an accumulating output stream must be handed off to an extenal client under contract that the stream should exhibit true Closable behaviour in response both to internally tracked events and to client invocation of the OutputStream.close() method. @author boucherb@users @version 1.9.0 @since 1.9.0
|
|