日期:2014-05-20 浏览次数:20670 次
public class MyServer { public static void main(String[] args) throws IOException { ServerSocket server = new ServerSocket(8854); Socket client = server.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter out = new PrintWriter(client.getOutputStream()); while(true) { String str = in.readLine(); System.out.println(str); out.println("has receive..."); out.flush(); if(str.equals("end")) break; } client.close(); } }