反序列化pbf编码的文件

时间:2018-08-06 08:46:25

标签: java proto

我正在使用一个名为SharedStreets-Matcher https://github.com/sharedstreets/sharedstreets-matcher的github项目。它使用Google的protobuf技术生成一个speeds pbf编码文件。

     FileInputStream inputStream = new FileInputStream(s);


    SharedStreetsSpeedsProto.SharedStreetsWeeklySpeeds  speedData  = S haredStreetsSpeedsProto.SharedStreetsWeeklySpeeds.newBuilder().mergeFrom(inputStream).build();

    System.out.println( speedData .getReferenceId());

原始文件就是这个https://github.com/sharedstreets/sharedstreets-ref-system/blob/master/proto/speeds.proto。我在做什么错了?

这是我得到的错误。

   Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
at com.google.protobuf.InvalidProtocolBufferException.invalidEndTag(InvalidProtocolBufferException.java:110)
at com.google.protobuf.CodedInputStream$StreamDecoder.checkLastTagWas(CodedInputStream.java:2126)
at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:249)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:604)
at io.sharedstreets.matcher.BatchMatcher.main(BatchMatcher.java:46)

0 个答案:

没有答案