Hi, I need some basic foreground for Java serialization for Protocol buffers. I found very strange behavior for me when I serialize ProtocolBuffer object directly with .toByteArray() method and with ByteArrayOutputStream.ToByteArray().
The code (first serialize with .toByteArray() directly): ...................... ProtocolBufferMsgHelper testObject = new ProtocolBufferMsgHelper(); // -> this is object instance created automatically from .proto file (proto2) byte[] byteArray = testObject.toByteArray(); ..................... -> Inside byteArray is { 8, 1, 18, 7, 71, ... } and the byteArray length is 20 bytes Second way (serialize with ByteArrayOutputStream): .................. ProtocolBufferMsgHelper testObject = new ProtocolBufferMsgHelper(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); testObject.writeDelimitedTo(bos); byte[] byteArray = bos.toByteArray(); .................. -> Inside byteArray is { 11, 8, 1, 18, 7, 71, ... } and the byteArray length is 21 bytes Why???? Could anyone tell me the reason?? Thanks, Jiri -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.