Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top