Hi,
I am new to protocol buffers, and I am trying to serialize a message
to a file. I need to serialize the file so that in can be opened in
Java using parseDelimitedFrom(). However, when I write to the file
using SerializeToCodedStream or SerializeWithCachedSizes, nothing
happens to the serializedMessage.bin file, and it stays at 0 bytes.
Why is nothing being written to the file? I have attached the code
below:
int fd = open("serializedMessage.bin", O_WRONLY);
google::protobuf::io::ZeroCopyOutputStream* fileOutput = new
google::protobuf::io::FileOutputStream(fd);
google::protobuf::io::CodedOutputStream* codedOutput = new
google::protobuf::io::CodedOutputStream(fileOutput);
codedOutput->WriteVarint32(message1.ByteSize());
message1.SerializeToCodedStream(codedOutput);
// also tried snap1.SerializeWithCachedSizes(codedOutput)
close(fd);
Thanks!
--
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.