日期:2014-05-20 浏览次数:20782 次
Socket socket = server.accept(); BufferedReader bfr = new BufferedReader(new InputStreamReader(socket.getInputStream())); StringBuffer messageContent = new StringBuffer(); while(bfr.readLine() != null) { messageContent.append(bfr.readLine()); } StringBuffer messageRecord = new StringBuffer(showMessage.getText()); messageRecord.append(messageContent.toString()); messageRecord.append("\n"); showMessage.setText(messageRecord.toString());
Socket socket = new Socket("127.0.0.1",8889); PrintWriter out = new PrintWriter(socket.getOutputStream(),true); out.println(messageContent); out.flush(); out.close();