How do I read protobuf.txt file in Java

31 views
Skip to first unread message

Amrit Jain

unread,
Jul 30, 2021, 3:54:04 AMJul 30
to GTFS-realtime

Hi,

I was able to generate java class using protoc compiler with help of proto file.
Now how to I consume protobuf.txt file in that class?
I have attached java class and sample file for reference.


sample.txt
GtfsRealtime.java

Amrit Jain

unread,
Jul 30, 2021, 4:02:57 AMJul 30
to GTFS-realtime
I get this error
Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException: Protocol message tag had invalid wire type.
When I try to run.
I used protoc compiler -3.17.3.

Sean Barbeau

unread,
Aug 3, 2021, 12:45:28 PMAug 3
to GTFS-realtime
Hi,
Your compiled Java application will need to consume the binary protocol buffer message (not the plain text version). You can read more about this here:

Note there are pre-compile Java bindings that you can use as a library here:

Sean

Sean Barbeau
Center for Urban Transportation Research
University of South Florida

Reply all
Reply to author
Forward
0 new messages