Class ByteString.Output (3.19.4)

public static final class ByteString.Output extends OutputStream

Outputs to a ByteString instance. Call #toByteString() to create the ByteString instance.

Inheritance

java.lang.Object > OutputStream > ByteString.Output

Methods

reset()

public synchronized void reset()

Resets this stream, so that all currently accumulated output in the output stream is discarded. The output stream can be used again, reusing the already allocated buffer space.

size()

public synchronized int size()

Returns the current size of the output stream.

Returns
TypeDescription
int

the current size of the output stream

toByteString()

public synchronized ByteString toByteString()

Creates a byte string with the size and contents of this output stream. This does not create a new copy of the underlying bytes. If the stream size grows dynamically, the runtime is O(log n) in respect to the number of bytes written to the Output. If the stream size stays within the initial capacity, the runtime is O(1).

Returns
TypeDescription
ByteString

the current contents of this output stream, as a byte string.

toString()

public String toString()
Returns
TypeDescription
String
Overrides

write(byte[] b, int offset, int length)

public synchronized void write(byte[] b, int offset, int length)
Parameters
NameDescription
bbyte[]
offsetint
lengthint
Overrides

write(int b)

public synchronized void write(int b)
Parameter
NameDescription
bint
Overrides

writeTo(OutputStream out)

public void writeTo(OutputStream out)

Writes the complete contents of this byte array output stream to the specified output stream argument.

Parameter
NameDescription
outOutputStream

the output stream to which to write the data.

Exceptions
TypeDescription
IOException

if an I/O error occurs.