public class BytesOutputStream extends OutputStream
toByteArray() and
array().
Closing a BytesOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
| Constructor and Description |
|---|
BytesOutputStream()
Creates a new byte array output stream.
|
BytesOutputStream(Bytes bytes)
The constructor wraps already existent
Bytes. |
BytesOutputStream(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 |
|---|---|
byte[] |
array()
Returns the byte array that backs this buffer.
|
void |
close() |
void |
reset()
Resets the 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.
|
void |
write(byte[] bytes,
int offset,
int length) |
void |
write(int value) |
flush, writepublic BytesOutputStream()
public BytesOutputStream(int size)
size - the initial size.IllegalArgumentException - if size is negative.public void write(int value)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] bytes,
int offset,
int length)
write in class OutputStreampublic void reset()
public int size()
public byte[] toByteArray()
ByteArrayOutputStream.size()public byte[] array()
Modifications to this buffer's content may cause the returned array's content to be modified, and vice versa.
public void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamCopyright © 2019–2020 Appulse. All rights reserved.