File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .fd .protobuf ;
2+
3+ import com .fd .protobuf .proto .AddressBookProtos ;
4+
5+ import java .io .*;
6+
7+ public class App {
8+
9+ public static void main (String [] args ) throws IOException {
10+ AddressBookProtos .Person furkan = AddressBookProtos .Person .newBuilder ()
11+ .setId (123 )
12+ .setName ("furkan danismaz" )
13+ .setEmail ("..." )
14+ .addPhones (
15+ AddressBookProtos .Person .PhoneNumber .newBuilder ()
16+ .setNumber ("555-1234" )
17+ .setType (AddressBookProtos .Person .PhoneType .MOBILE )
18+ .build ())
19+ .build ();
20+
21+ OutputStream os = new FileOutputStream (new File ("./output" ));
22+ furkan .writeTo (os );
23+
24+ InputStream is = new FileInputStream (new File ("./output" ));
25+ AddressBookProtos .Person parsedPerson = AddressBookProtos .Person .parseFrom (is );
26+
27+ System .out .println (parsedPerson );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments