Serializes the message to a byte array and returns it. This is just a trivial wrapper
around #writeTo(CodedOutputStream).
If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is
unpredictable. It may throw a runtime exception or truncate or slice the data.
Serializes the message to a ByteString and returns it. This is just a trivial wrapper
around #writeTo(CodedOutputStream).
If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is
unpredictable. It may throw a runtime exception or truncate or slice the data.
Like #writeTo(OutputStream), but writes the size of the message as a varint before
writing the data. This allows more data to be written to the stream after the message without
the need to delimit the message data yourself. Use Builder#mergeDelimitedFrom(InputStream) (or the static method
YourMessageType.parseDelimitedFrom(InputStream)) to parse messages written by this method.
Serializes the message and writes it to output. This is just a trivial wrapper around
#writeTo(CodedOutputStream). This does not flush or close the stream.
NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the
stream after the message, you must somehow ensure that the parser on the receiving end does not
interpret this as being part of the protocol message. This can be done e.g. by writing the size
of the message before the data, then making sure to limit the input to that size on the
receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively,
just use #writeDelimitedTo(OutputStream).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class AbstractMessageLite<MessageType,BuilderType> (3.19.4)\n\n public abstract class AbstractMessageLite\u003cMessageType,BuilderType\u003e implements MessageLite\n\nA partial implementation of the [MessageLite](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite) interface which implements as many methods of\nthat interface as possible in terms of other methods. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e AbstractMessageLite\\\u003cMessageType,BuilderType\\\u003e \n\nImplements\n----------\n\n[MessageLite](/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite) \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\nStatic Methods\n--------------\n\n### \\\u003cT\\\u003eaddAll(Iterable\\\u003cT\\\u003e values, Collection\\\u003c? super T\\\u003e list)\n\n protected static void \u003cT\u003eaddAll(Iterable\u003cT\u003e values, Collection\u003c? super T\u003e list)\n\n### \\\u003cT\\\u003eaddAll(Iterable\\\u003cT\\\u003e values, List\\\u003c? super T\\\u003e list)\n\n protected static void \u003cT\u003eaddAll(Iterable\u003cT\u003e values, List\u003c? super T\u003e list)\n\n### checkByteStringIsUtf8(ByteString byteString)\n\n protected static void checkByteStringIsUtf8(ByteString byteString)\n\nConstructors\n------------\n\n### AbstractMessageLite()\n\n public AbstractMessageLite()\n\nFields\n------\n\n### memoizedHashCode\n\n protected int memoizedHashCode\n\nMethods\n-------\n\n### toByteArray()\n\n public byte[] toByteArray()\n\nSerializes the message to a `byte` array and returns it. This is just a trivial wrapper\naround [#writeTo(CodedOutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeTo_).\n\nIf this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is\nunpredictable. It may throw a runtime exception or truncate or slice the data.\n\n### toByteString()\n\n public ByteString toByteString()\n\nSerializes the message to a `ByteString` and returns it. This is just a trivial wrapper\naround [#writeTo(CodedOutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeTo_).\n\nIf this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is\nunpredictable. It may throw a runtime exception or truncate or slice the data.\n\n### writeDelimitedTo(OutputStream output)\n\n public void writeDelimitedTo(OutputStream output)\n\nLike [#writeTo(OutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeTo_java_io_OutputStream_), but writes the size of the message as a varint before\nwriting the data. This allows more data to be written to the stream after the message without\nthe need to delimit the message data yourself. Use Builder#mergeDelimitedFrom(InputStream) (or the static method `\nYourMessageType.parseDelimitedFrom(InputStream)`) to parse messages written by this method.\n\n### writeTo(OutputStream output)\n\n public void writeTo(OutputStream output)\n\nSerializes the message and writes it to `output`. This is just a trivial wrapper around\n[#writeTo(CodedOutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeTo_). This does not flush or close the stream.\n\nNOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the\nstream after the message, you must somehow ensure that the parser on the receiving end does not\ninterpret this as being part of the protocol message. This can be done e.g. by writing the size\nof the message before the data, then making sure to limit the input to that size on the\nreceiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively,\njust use [#writeDelimitedTo(OutputStream)](/java/docs/reference/protobuf/latest/com.google.protobuf.AbstractMessageLite#com_google_protobuf_AbstractMessageLite_writeDelimitedTo_java_io_OutputStream_)."]]