当前位置:网站首页>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);
边栏推荐
- Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
- Software testing learning - the next day
- Practical plug-ins in idea
- UTC时间、GMT时间、CST时间
- Unittest attempt
- Centos切换安装mysql5.7和mysql8.0
- 修改MySQL密码
- 10000小時定律不會讓你成為編程大師,但至少是個好的起點
- Reading notes of "learn to ask questions"
- Selenium key knowledge explanation
猜你喜欢

Inno Setup 制作安装包

机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)

Practical plug-ins in idea

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

Specified interval inversion in the linked list
![[classes and objects] explain classes and objects in simple terms](/img/41/250457530880dfe3728432c2ccd50b.png)
[classes and objects] explain classes and objects in simple terms

VMware virtual machine C disk expansion

Operation principle of lua on C: Foundation

如何迁移或复制VMware虚拟机系统

Summary of the design and implementation of the weapon system similar to the paladin of vitality
随机推荐
DNS forward query:
Use the jvisualvm tool ----- tocmat to start JMX monitoring
利用C#实现Pdf转图片
Inno setup production and installation package
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
[set theory] partition (partition | partition example | partition and equivalence relationship)
Unit test framework + Test Suite
Operation principle of lua on C: Foundation
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
dataworks自定义函数开发环境搭建
Jenkins
Book recommendation~
Upgrade CentOS php7.2.24 to php7.3
【无标题】
2022年华东师范大学计科考研复试机试题-详细题解
IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library
Software testing assignment - day 3
error C2017: 非法的转义序列
centos php7.3安装redis扩展
Specified interval inversion in the linked list