当前位置:网站首页>Advanced API (batch image Download & socket dialog)
Advanced API (batch image Download & socket dialog)
2022-07-03 07:01:00 【Bugxiu_ fu】
File character stream :
* FileReader
* FileWriter
Read :
* One character array can be read at a time read(buf)
write in :
* write(char)
* write(char[] chs)
* write(String str)
Buffer flow
* BufferedReader
* BufferedWriter
*
* readLine();// Read a line
* newLine();// enjambment
* flush();// Refresh buffer
Converted flow
* InputStreamReader
* OutputStreamWriter
System.out.println("--------------- The server ----------------");
//1. Create server side adopt ServerSocket
ServerSocket ss = new ServerSocket(8989);
System.out.println("QQ Server turned on .... Wait for the client to connect !!!");
//2. Wait for a client to connect to the server
// adopt ss Object to call the method of the receiving client
Socket sk = ss.accept();// The way of blocking
System.out.println(" A client is online ......");
// Receive messages from clients
InputStream is = sk.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// Read a line
String readLine = br.readLine();
System.out.println(" client sb say : "+readLine);
// reply
OutputStream os = sk.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter bw = new BufferedWriter(osw);
// Send a message
Scanner sc = new Scanner(System.in);
System.out.println(" Please enter the content to send : ");
String content = sc.next();
bw.write(content);
bw.newLine();
bw.flush();
System.out.println("------------------------ client --------------------");
// 1. Use Socket Create client
Socket sk = new Socket(InetAddress.getByName("127.0.0.1"), 8989);
System.out.println(" Client on , Successfully connected to the server ");
// a key : When the client connects to the server Send a message Flow through the network
OutputStream os = sk.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter bw = new BufferedWriter(osw);
// Send a message
// String content = " Hello , The server ; I'm the client , I like drinking .";
Scanner sc = new Scanner(System.in);
System.out.println(" Please enter the content to send : ");
String content = sc.next();
bw.write(content);
bw.newLine();
bw.flush();
// Receive messages from clients
InputStream is = sk.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// Read a line
String readLine = br.readLine();
System.out.println(" The server sb say : " + readLine);
边栏推荐
- dataworks自定义函数开发环境搭建
- Summary of UI module design and practical application of agent mode
- 2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
- POI excel percentage
- The essence of interview
- 【code】偶尔取值、判空、查表、验证等
- Inno setup production and installation package
- 2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
- 【无标题】
- mongodb
猜你喜欢
[set theory] partition (partition | partition example | partition and equivalence relationship)
Setting up the development environment of dataworks custom function
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
JMeter JSON extractor extracts two parameters at the same time
Asynchronous programming: async/await in asp Net
Inno Setup 制作安装包
Software testing learning - day 3
[untitled]
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
Jenkins
随机推荐
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Stream stream
2021 year end summary
Laravel Web Framework
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
The essence of interview
Software testing assignment - the next day
php安装composer
SQL implementation merges multiple rows of records into one row
Tool class static method calls @autowired injected service
Unit test notes
Class and object summary
每日刷題記錄 (十一)
[untitled]
Integration test practice (1) theoretical basis
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
[Code] occasionally take values, judge blanks, look up tables, verify, etc
VMware virtual machine C disk expansion
[C /vb.net] convert PDF to svg/image, svg/image to PDF
2022年华东师范大学计科考研复试机试题-详细题解