多个异常捕获块Java 8 Eclipse [英] Multiple exception catch block java 8 eclipse

查看:70
本文介绍了多个异常捕获块Java 8 Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到IOException的未处理消息异常.正如您在粘贴的代码中看到的那样,我已经处理了IOException. Eclipse和Eclipse的JDK该项目是Java 8更新121,因此支持知道捕获多个异常.我在做什么错了?

I'm getting an unhandled message exception for IOException. As you can see in the pasted code I've handled the IOException. The JDK for both eclipse & the project is Java 8 update 121 so I know catching multiple exceptions is supported. What am I doing wrong?

    try (InputStream inputStream = BatchMessageProperties.class.getClassLoader().
            getResourceAsStream(propertiesFileName)) {

        load(inputStream);
        //need to make sure all properties are present & not null.
        validate(this);

    } catch (IOException | InvalidBatchMessagePropertiesFileException ex) {

        logger.error(ex.getLocalizedMessage());
        ex.printStackTrace();
        throw ex;
    }

推荐答案

您确实将ex扔到了catch块中,它可能是IOException,对吧?

You do rethrow ex inside your catch block, which may be an IOException, right?

这篇关于多个异常捕获块Java 8 Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆