当前位置:网站首页>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);
边栏推荐
- Liang Ning: 30 lectures on brain map notes for growth thinking
- 万卷书 - 价值投资者指南 [The Education of a Value Investor]
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
- JUC forkjoinpool branch merge framework - work theft
- JMeter JSON extractor extracts two parameters at the same time
- dataworks自定义函数开发环境搭建
- Summary of UI module design and practical application of agent mode
- 10000小時定律不會讓你成為編程大師,但至少是個好的起點
- Software testing assignment - day 1
- Resttemplate configuration use
猜你喜欢

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

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

Dbnet: real time scene text detection with differentiable binarization
![Gridome + strapi + vercel + PM2 deployment case of [static site (3)]](/img/65/8d79998e96a2c74ba6e237bee652c6.jpg)
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]

La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ

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

Pytest -- write and manage test cases

JMeter test result output

Sorting out the core ideas of the pyramid principle

Realize PDF to picture conversion with C #
随机推荐
php artisan
HMS core helps baby bus show high-quality children's digital content to global developers
On the practice of performance optimization and stability guarantee
卡特兰数(Catalan)的应用场景
Liang Ning: 30 lectures on brain map notes for growth thinking
How does the insurance company check hypertension?
Thoughts in Starbucks
Selenium key knowledge explanation
Arctic code vault contributor
Win 10 find the port and close the port
My 2020 summary "don't love the past, indulge in moving forward"
Crontab scheduled task
Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
Unit test notes
SQL implementation merges multiple rows of records into one row
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Asynchronous programming: async/await in asp Net
golang操作redis:写入、读取kv数据
PHP install the spool extension
golang操作redis:写入、读取hash类型数据