@NotThreadSafe
public final class ByteStringOutputStream
extends java.io.OutputStream
OutputStream
that produces ByteString
s.
Closing this output stream does nothing.
This class is not thread safe and expects appropriate locking to be used in a thread-safe
manner. This differs from ByteString.Output
which synchronizes its writes.
Constructor and Description |
---|
ByteStringOutputStream()
Creates a new output stream with a default capacity.
|
ByteStringOutputStream(int initialCapacity)
Creates a new output stream with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString |
consumePrefixToByteString(int prefixSize)
Creates a byte string with the given size containing the prefix of the contents of this output
stream.
|
int |
size()
Returns the current size of the output stream.
|
org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString |
toByteString()
Creates a byte string with the size and contents of this output stream.
|
org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString |
toByteStringAndReset()
Creates a byte string with the size and contents of this output stream and resets the output
stream to be re-used possibly re-using any existing buffers.
|
java.lang.String |
toString() |
void |
write(byte[] b,
int offset,
int length) |
void |
write(int b) |
public ByteStringOutputStream()
public ByteStringOutputStream(int initialCapacity)
initialCapacity
- the initial capacity of the output stream.public void write(int b)
write
in class java.io.OutputStream
public void write(byte[] b, int offset, int length)
write
in class java.io.OutputStream
public org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString toByteString()
Note that the caller must no longer use this object after this method. The internal buffer
is wrapped and thus mutations made by future write(int)
or other methods may mutate ByteString
s returned in the past.
public org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString toByteStringAndReset()
public org.apache.beam.vendor.grpc.v1p60p1.com.google.protobuf.ByteString consumePrefixToByteString(int prefixSize)
public int size()
public java.lang.String toString()
toString
in class java.lang.Object