Class BinaryWriter

java.lang.Object
com.google.protobuf.ByteOutput
com.google.protobuf.BinaryWriter
All Implemented Interfaces:
Writer
Direct Known Subclasses:
BinaryWriter.SafeDirectWriter, BinaryWriter.SafeHeapWriter, BinaryWriter.UnsafeDirectWriter, BinaryWriter.UnsafeHeapWriter

@CheckReturnValue @ExperimentalApi abstract class BinaryWriter extends ByteOutput implements Writer
A protobuf writer that serializes messages in their binary form. Messages are serialized in reverse in order to avoid calculating the serialized size of each nested message. Since the message size is not known in advance, the writer employs a strategy of chunking and buffer chaining. Buffers are allocated as-needed by a provided BufferAllocator. Once writing is finished, the application can access the buffers in forward-writing order by calling complete().

Once complete() has been called, the writer can not be reused for additional writes. The getTotalBytesWritten() will continue to reflect the total of the write and will not be reset.