private static FileBasedConfiguration createConfiguration(Reader reader) throws ConfigurationException { if (reader == null) { throw new NullPointerException("reader: null"); } FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(XMLConfiguration.class) .configure(new Parameters().xml()); FileBasedConfiguration fileBasedConfiguration = builder.getConfiguration(); FileHandler handler = new FileHandler(fileBasedConfiguration); handler.load(reader); return fileBasedConfiguration; }
private static Configuration loadConfiguration() throws IOException, ConfigurationException { Configurations configurations = new Configurations(); File file = Constants.SETTINGS_FILE_XML; if (!file.exists()) { XMLConfiguration tempConfiguration = new XMLConfiguration(); new FileHandler(tempConfiguration).save(file); } FileBasedConfigurationBuilder<XMLConfiguration> builder = configurations.xmlBuilder(file); builder.setAutoSave(true); return builder.getConfiguration(); }