I tried following code for encoding and decoding.
Decoding from byte[] fails, however.
Code:-
public static void test(){
Comment comment = Comment.newBuilder()
.setCommentBody("This is 1st comment")
.build();
byte[] bytes = comment.toByteArray();
try {
Comment c = Comment.parseFrom(bytes);
}
catch (InvalidProtocolBufferException ex) {
Logger.getLogger(testing.class.getName()).log(Level.SEVERE,
null, ex);
}
Exception details:-
Exception in thread "main" java.lang.RuntimeException: Uncompilable
source code
at
com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java)
at
com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:153)
at
com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:709)
at
paratha.serializers.protocolbuffers.CommentProto$Comment.parseFrom(CommentProto.java:186)
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.