多个异常捕获块 java 8 eclipse
Multiple exception catch block java 8 eclipse
我收到一个未处理的 IOException 消息异常。正如您在粘贴的代码中看到的那样,我已经处理了 IOException。 eclipse 和项目的 JDK 是 Java 8 update 121 所以我 知道 支持捕获多个异常。我做错了什么?
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;
}
你确实在你的 catch 块中重新抛出 ex
,这可能是一个 IOException
,对吧?
我收到一个未处理的 IOException 消息异常。正如您在粘贴的代码中看到的那样,我已经处理了 IOException。 eclipse 和项目的 JDK 是 Java 8 update 121 所以我 知道 支持捕获多个异常。我做错了什么?
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;
}
你确实在你的 catch 块中重新抛出 ex
,这可能是一个 IOException
,对吧?