Java Reference
In-Depth Information
The ByteArrayOutputStream class provides a dynamically growing byte ar-
ray to hold output. It adds constructors and methods:
public ByteArrayOutputStream()
Creates a new ByteArrayOutputStream with a default initial array
size.
public ByteArrayOutputStream(int size)
Creates a new ByteArrayOutputStream with the given initial ar-
ray size.
public int size()
Returns the number of bytes generated thus far by output to
the stream.
public byte[] toByteArray()
Returns a copy of the bytes generated thus far by output to
the stream. When you are finished writing into a ByteArrayOut-
putStream via upstream filter streams, you should flush the up-
stream objects before using toByteArray .
public void reset()
Resets the stream to reuse the current buffer, discarding its
contents.
public String toString()
Returns the current contents of the buffer as a String , trans-
lating bytes into characters according to the default character
encoding.
 
Search WWH ::




Custom Search