Class DirectByteArrayOutputStream
java.lang.Object
java.io.OutputStream
org.apache.catalina.tribes.io.DirectByteArrayOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Byte array output stream that exposes the byte array directly
-
Constructor Summary
ConstructorsConstructorDescriptionDirectByteArrayOutputStream(int size) Construct a new DirectByteArrayOutputStream with the given initial size. -
Method Summary
Methods inherited from class OutputStream
close, flush, nullOutputStream, write, write
-
Constructor Details
-
DirectByteArrayOutputStream
public DirectByteArrayOutputStream(int size) Construct a new DirectByteArrayOutputStream with the given initial size.- Parameters:
size- Initial size of the internal buffer
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
size
public int size()Get the current number of bytes written to this stream.- Returns:
- Number of bytes written
-
getArrayDirect
public byte[] getArrayDirect()Get the underlying byte array directly without copying.- Returns:
- Direct byte array reference
-
getArray
public byte[] getArray()Get a copy of the bytes written to this stream.- Returns:
- Copy of the byte array
-