package com.zy;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class Sever {
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//创建一个服务器端的对象
ServerSocket s = new ServerSocket(8888);
//服务器对象放入客户端
Socket ss = s.accept();
//获取读取流
InputStream sa = ss.getInputStream();
byte []b=new byte[1024];
while(sa.read(b)!=-1){
System.out.println(new String(b));
}
//断流
ss.shutdownInput();
//进行文件的写入
OutputStream sd = ss.getOutputStream();
String v="收到了";
sd.write(v.getBytes());
ss.shutdownOutput();
sd.flush();
sd.close();
sa.close();
ss.close();
s.close();
}
}