aboutsummaryrefslogtreecommitdiff
path: root/examples/ListPeople.java
diff options
context:
space:
mode:
authorBo Yang <paulyang1211@gmail.com>2018-01-23 15:46:06 -0800
committerBo Yang <paulyang1211@gmail.com>2018-01-23 15:46:06 -0800
commit99002ae47a3f88f64ff44dbd80452360e0e5fbc4 (patch)
treec711557f45024c07f22148bd7f8dc31d61081271 /examples/ListPeople.java
parenta721bf6d294915b412e4ba6b5d92a9b84c6bfef9 (diff)
downloadprotobuf-99002ae47a3f88f64ff44dbd80452360e0e5fbc4.tar.gz
protobuf-99002ae47a3f88f64ff44dbd80452360e0e5fbc4.tar.bz2
protobuf-99002ae47a3f88f64ff44dbd80452360e0e5fbc4.zip
Initialize python-wheel branch
Diffstat (limited to 'examples/ListPeople.java')
-rw-r--r--examples/ListPeople.java53
1 files changed, 0 insertions, 53 deletions
diff --git a/examples/ListPeople.java b/examples/ListPeople.java
deleted file mode 100644
index 580f7ac2..00000000
--- a/examples/ListPeople.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// See README.txt for information and build instructions.
-
-import com.example.tutorial.AddressBookProtos.AddressBook;
-import com.example.tutorial.AddressBookProtos.Person;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-class ListPeople {
- // Iterates though all people in the AddressBook and prints info about them.
- static void Print(AddressBook addressBook) {
- for (Person person: addressBook.getPeopleList()) {
- System.out.println("Person ID: " + person.getId());
- System.out.println(" Name: " + person.getName());
- if (!person.getEmail().isEmpty()) {
- System.out.println(" E-mail address: " + person.getEmail());
- }
-
- for (Person.PhoneNumber phoneNumber : person.getPhonesList()) {
- switch (phoneNumber.getType()) {
- case MOBILE:
- System.out.print(" Mobile phone #: ");
- break;
- case HOME:
- System.out.print(" Home phone #: ");
- break;
- case WORK:
- System.out.print(" Work phone #: ");
- break;
- default:
- System.out.println(" Unknown phone #: ");
- break;
- }
- System.out.println(phoneNumber.getNumber());
- }
- }
- }
-
- // Main function: Reads the entire address book from a file and prints all
- // the information inside.
- public static void main(String[] args) throws Exception {
- if (args.length != 1) {
- System.err.println("Usage: ListPeople ADDRESS_BOOK_FILE");
- System.exit(-1);
- }
-
- // Read the existing address book.
- AddressBook addressBook =
- AddressBook.parseFrom(new FileInputStream(args[0]));
-
- Print(addressBook);
- }
-}