Should class IOException in Java have been an unchecked RuntimeException?

前端 未结 6 1024
夕颜
夕颜 2021-02-05 05:29

Do you agree that the designers of Java class java.io.IOException should have made it an unchecked run-time exception derived from java.lang.RuntimeException<

6条回答
  •  天涯浪人
    2021-02-05 06:27

    I think it is clever to leave it a checked exception. I regard runtime exceptions as bugs, and this is clearly not the case. Recovery by retry is sometimes possible, and also some IOException messages can be informative to the end user (e.g. no permissions to write, not enough disk space, etc).

提交回复
热议问题