@Internal public class ExposedByteArrayOutputStream extends java.io.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.| 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. |
public void writeAndOwn(byte[] b)
throws java.io.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.
java.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
write in class java.io.ByteArrayOutputStreampublic void write(int b)
write in class java.io.ByteArrayOutputStreampublic byte[] toByteArray()
toByteArray in class java.io.ByteArrayOutputStreampublic void reset()
reset in class java.io.ByteArrayOutputStream