当前位置:网站首页>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);
边栏推荐
- Stream stream
- Shim and Polyfill in [concept collection]
- DBNet:具有可微分二值化的实时场景文本检测
- instanceof
- Reading notes of "learn to ask questions"
- Golang operation redis: write and read hash type data
- Troubleshooting of high CPU load but low CPU usage
- JMeter test result output
- golang操作redis:写入、读取hash类型数据
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
猜你喜欢
卡特兰数(Catalan)的应用场景
Setting up the development environment of dataworks custom function
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Operation principle of lua on C: Foundation
The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?
Summary of remote connection of MySQL
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
Summary of UI module design and practical application of agent mode
Mise en place d'un environnement de développement de fonctions personnalisées
随机推荐
Tool class static method calls @autowired injected service
Summary of the design and implementation of the weapon system similar to the paladin of vitality
How to migrate or replicate VMware virtual machine systems
Daily question brushing record (11)
Resttemplate configuration use
2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
error C2017: 非法的转义序列
Winter vacation work of software engineering practice
How does the insurance company check hypertension?
Selenium key knowledge explanation
DNS forward query:
Integration test practice (1) theoretical basis
Unit test notes
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
php artisan
Distributed ID
The dynamic analysis and calculation of expressions are really delicious for flee
How to plan well?
My 2020 summary "don't love the past, indulge in moving forward"
The essence of interview