How can I catch all the exceptions that will be thrown through reading and writing a file?

前端 未结 7 1393
眼角桃花
眼角桃花 2020-12-02 13:46

In Java, is there any way to get(catch) all exceptions instead of catch the exception individually?

7条回答
  •  温柔的废话
    2020-12-02 14:32

    Yes there is.

    try
    {
        //Read/write file
    }catch(Exception ex)
    {
        //catches all exceptions extended from Exception (which is everything)
    }
    

提交回复
热议问题