Package com.google.protobuf
Class ByteString.Output
- java.lang.Object
-
- java.io.OutputStream
-
- com.google.protobuf.ByteString.Output
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Enclosing class:
- ByteString
public static final class ByteString.Output extends java.io.OutputStream
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidreset()Resets this stream, so that all currently accumulated output in the output stream is discarded.intsize()Returns the current size of the output stream.ByteStringtoByteString()Creates a byte string with the size and contents of this output stream.java.lang.StringtoString()voidwrite(byte[] b, int offset, int length)voidwrite(int b)voidwriteTo(java.io.OutputStream out)Writes the complete contents of this byte array output stream to the specified output stream argument.
-
-
-
Method Detail
-
write
public void write(int b)
- Specified by:
writein classjava.io.OutputStream
-
write
public void write(byte[] b, int offset, int length)- Overrides:
writein classjava.io.OutputStream
-
toByteString
public 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 theByteString.Output. If the stream size stays within the initial capacity, the runtime is O(1).- Returns:
- the current contents of this output stream, as a byte string.
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOExceptionWrites the complete contents of this byte array output stream to the specified output stream argument.- Parameters:
out- the output stream to which to write the data.- Throws:
java.io.IOException- if an I/O error occurs.
-
size
public int size()
Returns the current size of the output stream.- Returns:
- the current size of the output stream
-
reset
public 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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-