当前位置:网站首页>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);
边栏推荐
- Flask Foundation
- 多个全局异常处理类,怎么规定执行顺序
- centos php7.2.24升级到php7.3
- mysql误删root账户导致无法登录
- Software testing learning - day 3
- [vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
- 2021 year end summary
- These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
- 【无标题】
- error C2017: 非法的转义序列
猜你喜欢

Use the jvisualvm tool ----- tocmat to start JMX monitoring

Dbnet: real time scene text detection with differentiable binarization

深度学习参数初始化(一)Xavier初始化 含代码

Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)

How to migrate or replicate VMware virtual machine systems

EasyExcel

Setting up the development environment of dataworks custom function

Software testing learning - the next day

Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record

Software testing learning - day 3
随机推荐
Thoughts on project development
2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution
Practice of enterprise ab/testing platform
JMeter test result output
Sorting out the core ideas of the pyramid principle
Resthighlevelclient gets the mapping of an index
Upgrade CentOS php7.2.24 to php7.3
golang操作redis:写入、读取hash类型数据
The education of a value investor
My 2020 summary "don't love the past, indulge in moving forward"
Software testing learning - day one
保险公司怎么查高血压?
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
vmware虚拟机C盘扩容
Selenium key knowledge explanation
Software testing assignment - the next day
Inno setup production and installation package
Thoughts in Starbucks
服务器如何设置多界面和装IIS呢?甜甜给你解答!