How to parse .pb files in Java?

2019-09-09 12:50发布

问题:

I have .proto and .pb files. I need to parse .pb file using Java. I don't about how to use this .pb files. Please can anybody help me to parse .pb files?

回答1:

Assuming that the *.pb file is a file whose content adheres to the *.proto specification, you can generate readers for the *.pb file using the protocol buffer code Google provides: http://code.google.com/p/protobuf/

There is a tutorial provided specific for Java, on how to generate the readers and deserialize the message. Have a look at https://developers.google.com/protocol-buffers/docs/javatutorial for more details.