public class Serverx {
public static void main(String args[]) throws IOException {
//创建对象并绑定端口
ServerSocket ss = new ServerSocket(10000);
//等待客户端连接
Socket socket = ss.accept();
//读取数据并保存到本地文件
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedWriter bh = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("d://新建文件夹//xiao.txt"), "UTF-8"));
String s;
while ((s = br.readLine()) != null) {
bh.write(s);
bh.newLine();
bh.flush();
}
socket.close();
ss.close();
}
}