Stay organized with collectionsSave and categorize content based on your preferences.
publicabstractclassByteOutput
An output target for raw bytes. This interface provides semantics that support two types of
writing:
Traditional write operations:(as defined byjava.io.OutputStream) where the
target method is responsible for either copying the data or completing the write before returning
from the method call.
Lazy write operations:where the caller guarantees that it will never modify the
provided buffer and it can therefore be considered immutable. The target method is free to
maintain a reference to the buffer beyond the scope of the method call (e.g. until the write
operation completes).
Writes a sequence of bytes. TheByteOutputmust copyvalueif it will not be
processed prior to the return of this method call, sincevaluemay be reused/altered by
the caller.
NOTE: This methodMUST NOTmodify thevalue. Doing so is a
programming error and will lead to data corruption which will be difficult to debug.
Writes a sequence of bytes. TheByteOutputmust copyvalueif it will not be
processed prior to the return of this method call, sincevaluemay be reused/altered by
the caller.
NOTE: This methodMUST NOTmodify thevalue. Doing so is a
programming error and will lead to data corruption which will be difficult to debug.
Writes a sequence of bytes. TheByteOutputis free to retain a reference to the value
beyond the scope of this method call (e.g. write later) since it is considered immutable and is
guaranteed not to change by the caller.
NOTE: This methodMUST NOTmodify thevalue. Doing so is a
programming error and will lead to data corruption which will be difficult to debug.
Writes a sequence of bytes. TheByteOutputis free to retain a reference to the value
beyond the scope of this method call (e.g. write later) since it is considered immutable and is
guaranteed not to change by the caller.
NOTE: This methodMUST NOTmodify thevalue. Doing so is a
programming error and will lead to data corruption which will be difficult to debug.
[[["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 ByteOutput (3.19.4)\n\n public abstract class ByteOutput\n\nAn output target for raw bytes. This interface provides semantics that support two types of\nwriting:\n\n**Traditional write operations:** (as defined by [java.io.OutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html)) where the\ntarget method is responsible for either copying the data or completing the write before returning\nfrom the method call.\n\n**Lazy write operations:** where the caller guarantees that it will never modify the\nprovided buffer and it can therefore be considered immutable. The target method is free to\nmaintain a reference to the buffer beyond the scope of the method call (e.g. until the write\noperation completes). \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e ByteOutput \n\nInherited Members\n-----------------\n\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\nConstructors\n------------\n\n### ByteOutput()\n\n public ByteOutput()\n\nMethods\n-------\n\n### write(byte value)\n\n public abstract void write(byte value)\n\nWrites a single byte.\n\n### write(byte\\[\\] value, int offset, int length)\n\n public abstract void write(byte[] value, int offset, int length)\n\nWrites a sequence of bytes. The [ByteOutput](/java/docs/reference/protobuf/latest/com.google.protobuf.ByteOutput) must copy `value` if it will not be\nprocessed prior to the return of this method call, since `value` may be reused/altered by\nthe caller.\n\nNOTE: This method **MUST NOT** modify the `value`. Doing so is a\nprogramming error and will lead to data corruption which will be difficult to debug.\n\n### write(ByteBuffer value)\n\n public abstract void write(ByteBuffer value)\n\nWrites a sequence of bytes. The [ByteOutput](/java/docs/reference/protobuf/latest/com.google.protobuf.ByteOutput) must copy `value` if it will not be\nprocessed prior to the return of this method call, since `value` may be reused/altered by\nthe caller.\n\nNOTE: This method **MUST NOT** modify the `value`. Doing so is a\nprogramming error and will lead to data corruption which will be difficult to debug.\n\n### writeLazy(byte\\[\\] value, int offset, int length)\n\n public abstract void writeLazy(byte[] value, int offset, int length)\n\nWrites a sequence of bytes. The [ByteOutput](/java/docs/reference/protobuf/latest/com.google.protobuf.ByteOutput) is free to retain a reference to the value\nbeyond the scope of this method call (e.g. write later) since it is considered immutable and is\nguaranteed not to change by the caller.\n\nNOTE: This method **MUST NOT** modify the `value`. Doing so is a\nprogramming error and will lead to data corruption which will be difficult to debug.\n\n### writeLazy(ByteBuffer value)\n\n public abstract void writeLazy(ByteBuffer value)\n\nWrites a sequence of bytes. The [ByteOutput](/java/docs/reference/protobuf/latest/com.google.protobuf.ByteOutput) is free to retain a reference to the value\nbeyond the scope of this method call (e.g. write later) since it is considered immutable and is\nguaranteed not to change by the caller.\n\nNOTE: This method **MUST NOT** modify the `value`. Doing so is a\nprogramming error and will lead to data corruption which will be difficult to debug."]]