BufferedReader readLine() blocks

前端 未结 7 2119
轻奢々
轻奢々 2020-12-06 02:02

When receiving data using readLine(), even though I put a \"\\n\" at the end of the message using the .flush when sending the message, the while loop that reads my message s

7条回答
  •  攒了一身酷
    2020-12-06 02:43

    The BufferedReader will keep on reading the input until it reaches the end (end of file or stream or source etc). In this case, the 'end' is the closing of the socket. So as long as the Socket connection is open, your loop will run, and the BufferedReader will just wait for more input, looping each time a '\n' is reached.

提交回复
热议问题