-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent2.java
More file actions
24 lines (20 loc) · 792 Bytes
/
Student2.java
File metadata and controls
24 lines (20 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package test;
import com.google.protobuf.InvalidProtocolBufferException;
import test.StudentOuterClass;
public class Student2 {
public static void main(String[] args) {
StudentOuterClass.Student.Builder buidler = StudentOuterClass.Student.newBuilder();
buidler.setName("Frank");
buidler.setNumber(123456);
buidler.setHobby("music");
StudentOuterClass.Student student = buidler.build();
System.out.println(student.toString());
byte[] array = student.toByteArray();
try {
StudentOuterClass.Student student1 = StudentOuterClass.Student.parseFrom(array);
System.out.println(student1.toString());
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
}