Java: what are IOEXceptions in BufferedReader's readLine() for?

后端 未结 6 2188
说谎
说谎 2021-02-06 03:13

I can \"fix\" the below exception with a try-catch loop but I cannot understand the reason.

  1. Why does the part \"in.readLine()\" continuosly ignite IOExceptions? <
6条回答
  •  庸人自扰
    2021-02-06 03:58

    1. It won't "continously ignite" them, it just might throw them each time you invoke it. In your case, if it throws something it means something has gone badly wrong with your standard input.
    2. The goal is to ensure that you, the programmer using the API, deals with the problem, since it is in general assumed to be a recoverable problem - although in your particular case it will be fatal for your whole program.

提交回复
热议问题