public class ByteArrayOutputStream extends OutputStream
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf
The buffer where data is stored.
|
protected int |
count
The number of valid bytes in the buffer.
|
Constructor and Description |
---|
ByteArrayOutputStream()
Creates a new byte array output stream.
|
ByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this output stream and releases any system resources associated with this stream.
|
void |
reset()
Resets the count field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded.
|
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
|
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
|
void |
write(int b)
Writes the specified byte to this byte array output stream.
|
flush, write
protected byte[] buf
protected int count
public ByteArrayOutputStream()
public ByteArrayOutputStream(int size)
public void close() throws IOException
close
in class OutputStream
IOException
public void reset()
public int size()
public byte[] toByteArray()
public String toString()
public void write(byte[] b, int off, int len)
write
in class OutputStream
public void write(int b)
write
in class OutputStream