资源简介
protobuf - 2.4.1.zip

代码片段和文件信息
// See README.txt for information and build instructions.
import com.example.tutorial.AddressBookProtos.AddressBook;
import com.example.tutorial.AddressBookProtos.Person;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
class AddPerson {
// This function fills in a Person message based on user input.
static Person PromptForAddress(BufferedReader stdin
PrintStream stdout) throws IOException {
Person.Builder person = Person.newBuilder();
stdout.print(“Enter person ID: “);
person.setId(Integer.valueOf(stdin.readLine()));
stdout.print(“Enter name: “);
person.setName(stdin.readLine());
stdout.print(“Enter email address (blank for none): “);
String email = stdin.readLine();
if (email.length() > 0) {
person.setEmail(email);
}
while (true) {
stdout.print(“Enter a phone number (or leave blank to finish): “);
String number = stdin.readLine();
if (number.length() == 0) {
break;
}
Person.PhoneNumber.Builder phoneNumber =
Person.PhoneNumber.newBuilder().setNumber(number);
stdout.print(“Is this a mobile home or work phone? “);
String type = stdin.readLine();
if (type.equals(“mobile“)) {
phoneNumber.setType(Person.PhoneType.MOBILE);
} else if (type.equals(“home“)) {
phoneNumber.setType(Person.PhoneType.HOME);
} else if (type.equals(“work“)) {
phoneNumber.setType(Person.PhoneType.WORK);
} else {
stdout.println(“Unknown phone type. Using default.“);
}
person.addPhone(phoneNumber);
}
return person.build();
}
// Main function: Reads the entire address book from a file
// adds one person based on user input then writes it back out to the same
// file.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println(“Usage: AddPerson ADDRESS_BOOK_FILE“);
System.exit(-1);
}
AddressBook.Builder addressBook = AddressBook.newBuilder();
// Read the existing address book.
try {
FileInputStream input = new FileInputStream(args[0]);
addressBook.mergeFrom(input);
input.close();
} catch (FileNotFoundException e) {
System.out.println(args[0] + “: File not found. Creating a new file.“);
}
// Add an address.
addressBook.addPerson(
PromptForAddress(new BufferedReader(new InputStreamReader(System.in))
System.out));
// Write the new address book back to disk.
FileOutputStream output = new FileOutputStream(args[0]);
addressBook.build().writeTo(output);
output.close();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-04-30 17:52 protobuf-2.4.1\
目录 0 2011-04-30 17:52 protobuf-2.4.1\editors\
文件 221 2011-04-30 17:52 protobuf-2.4.1\editors\README.txt
文件 3774 2011-04-30 17:22 protobuf-2.4.1\editors\proto.vim
文件 7798 2011-04-30 17:22 protobuf-2.4.1\editors\protobuf-mode.el
目录 0 2011-04-30 17:52 protobuf-2.4.1\examples\
文件 1548 2011-04-30 17:52 protobuf-2.4.1\examples\README.txt
文件 2299 2011-04-30 17:22 protobuf-2.4.1\examples\Makefile
文件 637 2011-04-30 17:22 protobuf-2.4.1\examples\addressbook.proto
文件 2617 2011-04-30 17:22 protobuf-2.4.1\examples\add_person.cc
文件 1977 2011-04-30 17:22 protobuf-2.4.1\examples\list_people.cc
文件 2861 2011-04-30 17:22 protobuf-2.4.1\examples\AddPerson.java
文件 1604 2011-04-30 17:22 protobuf-2.4.1\examples\ListPeople.java
文件 1656 2011-04-30 17:22 protobuf-2.4.1\examples\add_person.py
文件 1135 2011-04-30 17:22 protobuf-2.4.1\examples\list_people.py
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\main\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\main\java\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\main\java\com\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\main\java\com\google\
目录 0 2011-04-30 17:52 protobuf-2.4.1\java\src\main\java\com\google\protobuf\
文件 27359 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\AbstractMessage.java
文件 11238 2011-04-30 17:22 protobuf-2.4.1\java\src\main\java\com\google\protobuf\AbstractMessageLite.java
文件 2323 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\BlockingRpcChannel.java
文件 2703 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\BlockingService.java
文件 11737 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\ByteString.java
文件 30627 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\CodedInputStream.java
文件 38057 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\CodedOutputStream.java
文件 68365 2011-04-30 17:21 protobuf-2.4.1\java\src\main\java\com\google\protobuf\Desc
文件 14885 2011-04-30 17:22 protobuf-2.4.1\java\src\main\java\com\google\protobuf\DynamicMessage.java
............此处省略550个文件信息
- 上一篇:左斜体的一种字体
- 下一篇:额温枪STM8L方案含原理图和代码.rar
相关资源
- J2EE 配置文件
-
开源tinyxm
l - 常用编码(UnicodeUTF-8GBK)转换工具
-
图片和xm
l格式互换 -
xm
l多个文件合并(delphi) -
xm
l课件及例题(xm l) -
《xm
l编程原理与实例教程》电子教 -
将数据库的表生成xm
l文件 -
简单的xm
l投票系统 -
notepad++包含xm
l tools等插件 -
Volley获取json和xm
l数据解析显示 -
李刚疯狂xm
l讲义第2版完整源码 -
maven settings.xm
l 直接使用 - Unity3D 实战视频教程 保卫萝卜 2D 游戏
-
Notepad++的xm
l格式化工具xm ltools_2 -
Notepad++的xm
l Tools插件格式化xm l文 -
map/list集合转化成xm
l字符串 xm l字 -
libxm
l2-2.9.4-rc2.tar.gz - antisamy策略文件
- 在线教学系统微信小程序
-
Tinyxm
l库文件 - protobuf-2.5.0269634
-
优秀xm
l程序设计(学生信息管理) -
svnmaven xm
l Schema等程序员必备.7z - protoc-3.11.4-win64.zip
-
xm
l基础教程-耿祥义 清华出版社 -
xm
l基础教程 第二版 PDF -
一个xm
l项目源代码 - netty+protobuf 整合源代码
- 订单管理系统SSH框架
评论
共有 条评论