You have to flush the CodedOutputStream. You should just do this instead: byte[] data = person.build().toByteArray();
On Thu, Jul 2, 2009 at 12:44 AM, J.V. <jvsr...@gmail.com> wrote: > > I'm trying to get the following to work but nothing is being written to > the output stream. > any ideas? > > private void testEncode() throws Exception { > OutputStream out = new ByteArrayOutputStream(); > CodedOutputStream cos = CodedOutputStream.newInstance(out); > > Person.person.Builder person = Person.person.newBuilder(); > person.setFirstName("First"); > person.setLastName("Last"); > person.build().writeTo(cos); > } > > When I try to decode cos it throws an exception > Exception in thread "main" > com.google.protobuf.InvalidProtocolBufferException: Protocol message > contained an invalid tag (zero). > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---