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/>");