- package com.itheima;
- import java.io.*;
- import java.net.*;
- public class Test7
- {
- public static void main(String[] args) throws IOException
- {
- ServerSocket ss = new ServerSocket(10000);
- Socket s = ss.accept();
- BufferedReader bfr = new BufferedReader(new InputStreamReader(s.getInputStream()));
- PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
- String zfc= bfr.readLine();
- int len = zfc.length();
- char[] chars = new char[len];
- for(int i = 0; i < len; i++)
- chars[i] = zfc.charAt(len - 1 - i);
- pw.println(chars);
- }
- }
-
- class Kehu
- {
- public static void main(String[] args) throws UnknownHostException, IOException
- {
- Socket s = new Socket("192.168.1.254",10000);
- BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
- PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
- BufferedReader bfrout = new BufferedReader(new InputStreamReader(s.getInputStream()));
- String zfc = bfr.readLine();
- pw.println(zfc);
- String fzzfc = bfrout.readLine();
- System.out.println(bfrout);
- pw.close();
- s.close();
- }
- }
复制代码 代码就不写注释了 |