package com.cskaoyan._28day;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;
public class _4Exercise {
public static void main(String[] args) throws IOException {
// 创建Socket对象
Socket socket = new Socket("127.0.0.1",10246);
//键盘录入
System.out.println("请输入文本文件");
Scanner sc = new Scanner(System.in);
//键盘接收
String s =sc.nextLine();
// 获取输出流
OutputStream out = socket.getOutputStream();
//write方法写数据
out.write(s.getBytes());
// 接收数据流
InputStream in = socket.getInputStream();
// read数据
String response = NetworkUtils.readBytesTOString(in);
System.out.println(response);
// close
socket.close();
}
}