当前位置:网站首页>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);
边栏推荐
- Software testing learning - day one
- Architecture notes
- [vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
- golang操作redis:写入、读取kv数据
- vmware虚拟机C盘扩容
- 【code】偶尔取值、判空、查表、验证等
- File links cannot be opened or downloaded in Google browser
- Personally design a highly concurrent seckill system
- Specified interval inversion in the linked list
- 2022年华东师范大学计科考研复试机试题-详细题解
猜你喜欢

Mise en place d'un environnement de développement de fonctions personnalisées

2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)

Integration test practice (1) theoretical basis

dataworks自定义函数开发环境搭建

Software testing learning - day 3

The 10000 hour rule won't make you a master programmer, but at least it's a good starting point

2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)

In depth analysis of reentrantlock fair lock and unfair lock source code implementation

Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
![[untitled]](/img/72/4ff9354634342580a135debb58b60e.jpg)
[untitled]
随机推荐
centos php7.2.24升级到php7.3
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
POI excel percentage
Interfaces and related concepts
[classes and objects] explain classes and objects in simple terms
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
【类和对象】深入浅出类和对象
2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Liang Ning: 30 lectures on brain map notes for growth thinking
Architecture notes
EasyExcel
Tool class static method calls @autowired injected service
dataworks自定义函数开发环境搭建
JMeter test result output
CentOS php7.3 installing redis extensions
Software testing assignment - day 3
How to specify the execution order for multiple global exception handling classes
DBNet:具有可微分二值化的实时场景文本检测
Unit test framework + Test Suite