Example usage for java.io FileNotFoundException addSuppressed

List of usage examples for java.io FileNotFoundException addSuppressed

Introduction

In this page you can find the example usage for java.io FileNotFoundException addSuppressed.

Prototype

public final synchronized void addSuppressed(Throwable exception) 

Source Link

Document

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.

Usage

From source file:org.apache.asterix.common.config.AsterixPropertiesAccessor.java

private AsterixConfiguration configure(String fileName) throws IOException, AsterixException {
    try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
        if (is != null) {
            return configure(is, fileName);
        }//www  . j  a va2s .c o  m
    }
    try (FileInputStream is = new FileInputStream(fileName)) {
        return configure(is, fileName);
    } catch (FileNotFoundException fnf1) {
        LOGGER.warn(
                "Failed to get configuration file " + fileName + " as FileInputStream. FileNotFoundException");
        LOGGER.warn("Attempting to get default configuration file " + GlobalConfig.DEFAULT_CONFIG_FILE_NAME
                + " as FileInputStream");
        try (FileInputStream fis = new FileInputStream(GlobalConfig.DEFAULT_CONFIG_FILE_NAME)) {
            return configure(fis, GlobalConfig.DEFAULT_CONFIG_FILE_NAME);
        } catch (FileNotFoundException fnf2) {
            fnf1.addSuppressed(fnf2);
            throw new AsterixException("Could not find configuration file " + fileName, fnf1);
        }
    }
}