Serialize/Unserialize protobuf

Moki Lv6
1
2
3
4
5
6
7
8
ByteArrayOutputStream buffer = new ByteArrayOutputStream();

ProtobufMessageClass.newBuilder()
.set(...)
.build()
.writeTo(buffer);

byte[] serialized = buffer.toByteArray();
1
ProtobufMessageClass unserialized = ProtobufMessageClass.newBuilder().mergeFrom(serialized).build();
On this page
Serialize/Unserialize protobuf