Unreachable catch block for IOException. This exception is never thrown from the try statement body

Unreachable catch block for IOException. This exception is never thrown from the try statement body

不可到达的 catch 异常try 中的语句永远不会引发异常

《Unreachable catch block for IOException. This exception is never thrown from the try statement body》

2 quick fixes available

2 快速修复可用

《Unreachable catch block for IOException. This exception is never thrown from the try statement body》

点击其中一个,可以解决这个问题。

2016-12-19补充

注意:我这里捕获的异常类型是“IOException”,而异常的类型有很多,

当你的代码确实会抛出异常而你又不知道异常的具体类型时,请改用“Exception”,这是所有异常的基类。

如果你改用“Exception”了还是出现些错误提示,说明你的代码不会产生异常,需要把try catch 块去掉解决此问题,

也就是使用上面的方法:quick fixes ava

点赞