That one will parse from binary encoded data. Looks like your sample_message.txt is in ASCII format. In short: Binary format: serialize: msg.writeTo() / msg.toByteArray() parsing: MyMessage.parseFrom() / builder.mergeFrom()
ASCII format: serialize: msg.toString() / TextFormat.printToString() parsing: TextFormat.merge() You should use them in pair. On Thu, May 26, 2011 at 1:18 AM, ch007 <[email protected]> wrote: > Hi all, > > I wrote a reading class to print the data in the message to the > console. the problem is i am not able to print any thing on the > console. code is running fine. I think the problem is with the > following part. > > File myFile = new File ("C:/Documents and Settings/ch007/Desktop/ > sample_message.txt"); > FileInputStream fis = new FileInputStream(myFile); > Good good = Good.parseFrom(fis); > if(good==null) > { > System.out.println("problem in reading message"); > > } > if(good.hasMessageId()) > { > System.out.println("MessageId: "+good.getMessageId()); > } > > > in the sample_message.txt there is messageid but in the output it is > not printing any messaage id. Same problem with all other fields.I am > not able to get any of the fields. I followed the address book > tutorial and trid to implement this. please help me > Is the below line correct? > Nta2Sse nta2sse = Nta2Sse.parseFrom(fis); > > > 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. > > -- 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.
