Does protobuf java support initialization from text?

In c++, we could use google::protobuf::TextFormat::Parse(input, proto) to initialize the proto with the inputStream input, if input satisfies some format.

Does protobuf java support this feature? if yes, what is the file format? Thanks a lot.

Jon Skeet
people
quotationmark

Yes, using the same text file format.

Just use TextFormat.merge, passing in either the text itself as a CharSequence or a Readable (e.g. Reader) and a builder to merge the values into.

See the Javadoc for TextFormat for more information, and be aware that it's not available in the "lite" runtime.

people

See more on this question at Stackoverflow