public class ExposedByteArrayOutputStream extends ByteArrayOutputStream
ByteArrayOutputStream special cased to treat writes of a single byte-array specially.
When calling toByteArray() after writing only one byte[] using
writeAndOwn(byte[]), it will return that array directly.buf, count| Constructor and Description |
|---|
ExposedByteArrayOutputStream() |
| Modifier and Type | Method and Description |
|---|---|
void |
reset() |
byte[] |
toByteArray() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeAndOwn(byte[] b)
Write
b to the stream and take the ownership of b. |
close, size, toString, toString, toString, writeToflush, writepublic void writeAndOwn(byte[] b)
throws IOException
b to the stream and take the ownership of b.
If the stream is empty, b itself will be used as the content of the stream and
no content copy will be involved.
Note: After passing any byte array to this method, it must not be modified again.
IOExceptionpublic void write(byte[] b,
int off,
int len)
write in class ByteArrayOutputStreampublic void write(int b)
write in class ByteArrayOutputStreampublic byte[] toByteArray()
toByteArray in class ByteArrayOutputStreampublic void reset()
reset in class ByteArrayOutputStream