Package org.apache.pekko.http.impl.util
Class ByteStringOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
org.apache.pekko.http.impl.util.ByteStringOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
INTERNAL API
An OutputStream that buffers into a byte array like ByteArrayOutputStream but
that can hand the buffered data over as a pekko.util.ByteString without copying it, unlike
ByteArrayOutputStream.toByteArray which always creates a copy.
Derived from the ByteStringOutputStream in Apache Pekko gRPC
(https://github.com/apache/pekko-grpc/pull/862).
-
Field Summary
Fields inherited from class java.io.ByteArrayOutputStream
buf, count -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pekko.util.ByteStringWraps the bytes written so far in aByteString.Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeToMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
ByteStringOutputStream
public ByteStringOutputStream(int capacity)
-
-
Method Details
-
toByteStringUnsafe
public org.apache.pekko.util.ByteString toByteStringUnsafe()Wraps the bytes written so far in aByteString. The buffer may be shared with the returnedByteString, so this stream must not be written to, reset or reused afterwards.- Returns:
- (undocumented)
-