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.
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 theOutput. If the stream size
stays within the initial capacity, the runtime is O(1).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class ByteString.Output (3.19.4)\n\n public static final class ByteString.Output extends OutputStream\n\nOutputs to a `ByteString` instance. Call [#toByteString()](/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.Output#com_google_protobuf_ByteString_Output_toByteString__) to create the `\nByteString` instance. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e [OutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html) \\\u003e ByteString.Output \n\nInherited Members\n-----------------\n\n[OutputStream.close()](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#close--) \n[OutputStream.flush()](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#flush--) \n[OutputStream.nullOutputStream()](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#nullOutputStream--) \n[OutputStream.write(byte\\[\\])](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#write-byte[]-) \n[OutputStream.write(byte\\[\\],int,int)](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#write-byte[]-int-int-) \n[OutputStream.write(int)](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#write-int-) \n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nMethods\n-------\n\n### reset()\n\n public synchronized void reset()\n\nResets this stream, so that all currently accumulated output in the output stream is\ndiscarded. The output stream can be used again, reusing the already allocated buffer space.\n\n### size()\n\n public synchronized int size()\n\nReturns the current size of the output stream.\n\n### toByteString()\n\n public synchronized ByteString toByteString()\n\nCreates a byte string with the size and contents of this output stream. This does not create\na new copy of the underlying bytes. If the stream size grows dynamically, the runtime is\nO(log n) in respect to the number of bytes written to the Output. If the stream size\nstays within the initial capacity, the runtime is O(1).\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)\n\n### write(byte\\[\\] b, int offset, int length)\n\n public synchronized void write(byte[] b, int offset, int length)\n\n**Overrides** \n[OutputStream.write(byte\\[\\],int,int)](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#write-byte[]-int-int-)\n\n### write(int b)\n\n public synchronized void write(int b)\n\n**Overrides** \n[OutputStream.write(int)](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html#write-int-)\n\n### writeTo(OutputStream out)\n\n public void writeTo(OutputStream out)\n\nWrites the complete contents of this byte array output stream to the specified output stream\nargument."]]