-
大小: 12.43MB文件類型: .zip金幣: 1下載: 0 次發布日期: 2023-06-17
- 語言: 其他
- 標簽:
資源簡介
深度學習所用protobuf。tensorflow依賴與該資源,需要通過其中的protoc對指定目錄進行編譯。
代碼片段和文件信息
//?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]);
??????try?{
????????addressBook.mergeFrom(input);
??????}?finally?{
????????try?{?input.close();?}?catch?(Throwable?ignore)?{}
??????}
????}?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]);
????try?{
??????addressBook.build().writeTo(output);
????}?finally?{
??????output.close();
????}
??}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-05-08?16:10??pro26\
?????目錄???????????0??2014-08-26?07:27??pro26\protobuf-2.6.0\
?????文件?????2609846??2018-05-08?16:10??pro26\protobuf-2.6.0.tar.gz
?????文件?????3305551??2018-05-08?15:37??pro26\protobuf-2.6.0.zip
?????文件???????36976??2014-08-26?04:20??pro26\protobuf-2.6.0\aclocal.m4
?????文件????????1519??2014-08-26?03:52??pro26\protobuf-2.6.0\autogen.sh
?????文件???????27793??2014-08-26?07:27??pro26\protobuf-2.6.0\CHANGES.txt
?????文件???????44826??2014-08-26?04:20??pro26\protobuf-2.6.0\config.guess
?????文件????????3709??2014-08-26?04:20??pro26\protobuf-2.6.0\config.h.in
?????文件???????35454??2014-08-26?04:20??pro26\protobuf-2.6.0\config.sub
?????文件??????599150??2014-08-26?04:20??pro26\protobuf-2.6.0\configure
?????文件????????4847??2014-08-26?03:52??pro26\protobuf-2.6.0\configure.ac
?????文件????????3617??2014-08-26?07:27??pro26\protobuf-2.6.0\CONTRIBUTORS.txt
?????文件????????1765??2014-08-26?07:27??pro26\protobuf-2.6.0\COPYING.txt
?????文件???????20334??2014-08-26?04:20??pro26\protobuf-2.6.0\depcomp
?????目錄???????????0??2014-08-26?07:27??pro26\protobuf-2.6.0\editors\
?????文件????????3731??2014-08-26?03:52??pro26\protobuf-2.6.0\editors\proto.vim
?????文件????????7798??2014-08-26?03:52??pro26\protobuf-2.6.0\editors\protobuf-mode.el
?????文件?????????221??2014-08-26?07:27??pro26\protobuf-2.6.0\editors\README.txt
?????目錄???????????0??2014-08-26?07:27??pro26\protobuf-2.6.0\examples\
?????文件????????2975??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\AddPerson.java
?????文件?????????637??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\addressbook.proto
?????文件????????2617??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\add_person.cc
?????文件????????1656??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\add_person.py
?????文件????????1604??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\ListPeople.java
?????文件????????2036??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\list_people.cc
?????文件????????1135??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\list_people.py
?????文件????????2299??2014-08-26?03:52??pro26\protobuf-2.6.0\examples\Makefile
?????文件????????1548??2014-08-26?07:27??pro26\protobuf-2.6.0\examples\README.txt
?????文件????????1105??2014-08-26?03:52??pro26\protobuf-2.6.0\generate_desc
?????目錄???????????0??2014-08-26?07:27??pro26\protobuf-2.6.0\gtest\
............此處省略694個文件信息
- 上一篇:城市建筑模型地理數據 武漢市建筑數據
- 下一篇:Screenpresso.exe
評論
共有 條評論