package Demo01;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) {
try {
ServerSocket socket=new ServerSocket(8810);
System.out.println(" 服务器已经启动.....请连接");
Socket socket2=socket.accept();
BufferedReader br=new BufferedReader(new InputStreamReader(socket2.getInputStream(),"UTF-8"));
int r;
while((r=br.read())!=-1){
System.out.print((char)r);
}
System.out.println();
br.close();
socket2.close();
socket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
|