为什么这里的代码在从字段中获取消息后使用类flush()
的方法......?PrintWriter
messageBox
public void connectToSocket() {
try {
Socket socket = new Socket("localhost", 80);
PrintWriter writer = new PrintWriter(socket.getOutputStream);
System.out.println("Connected Successfully");
}
catch(IOException ex) {
ex.printStackTrace();
}
}
public class sendMessageListener implements ActionListener {
try {
writer.println(messageBox.getText());
writer.flush();
}
catch(IOException ex) {
ex.printStackTrace();
}
}