日期:2014-05-20 浏览次数:20716 次
public class Server { public static void main(String[] args) throws Exception{ ServerSocket server = new ServerSocket(5150); Socket client = server.accept(); InputStream in = client.getInputStream(); //这里设置读长度为1024,你可以考虑循环读取 byte[] b = new byte[1024]; int i = in.read(b); System.out.println(new String(b, 0, i)); } }