How should I read from a buffered reader?

前端 未结 9 961
無奈伤痛
無奈伤痛 2020-12-06 08:26

I have the following example of reading from a buffered reader:

while ((inputLine = input.readLine()) != null) {
   System.out.println(\"I got a message from         


        
9条回答
  •  离开以前
    2020-12-06 08:51

    input reader is connected to the socket, which is a listener, i.e. keeps listening to incoming messages.

    About your second question, you should put a try/catch block inside the method, catch the Exception and handle it. Do not re-throw it.

提交回复
热议问题