| java.lang.Object | ||
| ↳ | java.io.OutputStream | |
| ↳ | java.io.ByteArrayOutputStream | |
ByteArrayOutputStream is a class whose underlying stream is represented by a byte array. As bytes are written to this stream, the local byte array may be expanded to hold more bytes.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| buf | The byte array containing the bytes written. | ||||||||||
| count | The number of bytes written. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new ByteArrayOutputStream with a default size of 32 bytes.
| |||||||||||
Constructs a new ByteArrayOutputStream with a default size of
size bytes. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Close this ByteArrayOutputStream.
| |||||||||||
Reset this ByteArrayOutputStream to the beginning of the underlying byte
array.
| |||||||||||
Returns the total number of bytes written to this stream thus far.
| |||||||||||
Answer the contents of this ByteArrayOutputStream as a byte array.
| |||||||||||
Answer the contents of this ByteArrayOutputStream as a String.
| |||||||||||
Answer the contents of this ByteArrayOutputStream as a String converted
using the encoding declared in
enc. | |||||||||||
This method is deprecated.
Use toString()
| |||||||||||
Writes the specified byte
oneByte to the OutputStream. | |||||||||||
Writes
count bytes from the byte array
buffer starting at offset index to the
ByteArrayOutputStream. | |||||||||||
Take the contents of this stream and write it to the output stream
out. | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.OutputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.io.Flushable
| |||||||||||
The byte array containing the bytes written.
The number of bytes written.
Constructs a new ByteArrayOutputStream with a default size of 32 bytes. If more than 32 bytes are written to this instance, the underlying byte array will expand to accommodate.
Constructs a new ByteArrayOutputStream with a default size of
size bytes. If more than size bytes are
written to this instance, the underlying byte array will expand to
accommodate.
| size | an non-negative integer representing the initial size for the underlying byte array. |
|---|
Close this ByteArrayOutputStream. This implementation releases System resources used for this stream.
| IOException | If an error occurs attempting to close this OutputStream. |
|---|
Reset this ByteArrayOutputStream to the beginning of the underlying byte array. All subsequent writes will overwrite any bytes previously stored in this stream.
Returns the total number of bytes written to this stream thus far.
Answer the contents of this ByteArrayOutputStream as a byte array. Any changes made to the receiver after returning will not be reflected in the byte array returned to the caller.
Answer the contents of this ByteArrayOutputStream as a String. Any changes made to the receiver after returning will not be reflected in the String returned to the caller.
Answer the contents of this ByteArrayOutputStream as a String converted
using the encoding declared in enc.
| enc | A String representing the encoding to use when translating this stream to a String. |
|---|
| UnsupportedEncodingException | If declared encoding is not supported |
|---|
This method is deprecated.Use toString()
Answer the contents of this ByteArrayOutputStream as a String. Each byte
b in this stream is converted to a character
c using the following function:
c == (char)(((hibyte & 0xff) << 8) | (b & 0xff)). This
method is deprecated and either toString(), or toString(String)
should be used.
| hibyte | the high byte of each resulting Unicode character |
|---|
hibyteWrites the specified byte oneByte to the OutputStream.
Only the low order byte of oneByte is written.
| oneByte | the byte to be written |
|---|
Writes count bytes from the byte array
buffer starting at offset index to the
ByteArrayOutputStream.
| buffer | the buffer to be written |
|---|---|
| offset | offset in buffer to get bytes |
| len | number of bytes in buffer to write |
| NullPointerException | If buffer is null. |
|---|---|
| IndexOutOfBoundsException | If offset or count are outside of bounds. |
Take the contents of this stream and write it to the output stream
out.
| out | An OutputStream on which to write the contents of this stream. |
|---|
| IOException | If an error occurs when writing to output stream |
|---|