我有服务器的基本代码:
ServerSocket serverSocket = new ServerSocket(14000);
Socket clientSocket = serverSocket.accept();
BufferedReader in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
PrintWriter out = new PrintWriter(clientSocket.getOutputStream());
String incoming;
while((incoming = in.readLine()) != null){
System.out.println("Client Says: " + incoming);
out.println("Client Says: " + incoming);
out.flush();
//if(incoming.equals("HELLO")) break;
}
clientSocket.close();
serverSocket.close();
我正在尝试进一步了解流,因为它们让我非常头疼。根据我的阅读,println 方法会自动为您刷新,但是除非之后调用刷新方法,否则此行不会传递给客户端?我只是在寻找一个很好的可靠解释?