Why use IOexception instead of Exception when catching?

后端 未结 6 906
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 03:31

I can\'t seem to phrase this correctly for the search engine to pick up any meaningful results.

try{
    BufferedReader reader = new BufferedReader( new File         


        
6条回答
  •  北海茫月
    2020-12-18 04:19

    What if you want to do a different action with different exceptions? You can make a catch block for IOException and for example, make it show a message box. Then make another catch block for a FileNotFoundException and make it create a new file and try to open it again, or even rethrow the exception. Hope I explained myself correctly. Cheers!

提交回复
热议问题