public static final class ByteString.Output extends OutputStream
Outputs to a ByteString
instance. Call #toByteString() to create the
ByteString
instance.
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 | |
---|---|
Type | Description |
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 | |
---|---|
Type | Description |
ByteString | the current contents of this output stream, as a byte string. |
toString()
public String toString()
Returns | |
---|---|
Type | Description |
String |
write(byte[] b, int offset, int length)
public synchronized void write(byte[] b, int offset, int length)
Parameters | |
---|---|
Name | Description |
b | byte[] |
offset | int |
length | int |
write(int b)
public synchronized void write(int b)
Parameter | |
---|---|
Name | Description |
b | int |
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 | |
---|---|
Name | Description |
out | OutputStream the output stream to which to write the data. |
Exceptions | |
---|---|
Type | Description |
IOException | if an I/O error occurs. |