随笔 - 1, 文章 - 2, 评论 - 0, 引用 - 0
数据加载中……

Java Socket 服务器端示例代码

ServerSocket ss = new ServerSocket(9999);
Socket socket = ss.accept();
InputStreamReader isReader = new InputStreamReader(socket.getInputStream());
BufferedReader reader = new BufferedReader(isReader);
StringBuffer sb = new StringBuffer();
String line;
while((line=reader.readLine())!=null){
          sb.append(line);
}
FileWriter fos = new FileWriter("d:/aa.txt",true);
fos.write(sb.toString());
fos.write("\r\n");
fos.close();
socket.close();
ss.close();
out.print(sb.toString()+"<br/>");

posted on 2010-10-15 09:00 温凯旋 阅读(103) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: