List of usage examples for org.apache.commons.configuration2.builder FileBasedConfigurationBuilder FileBasedConfigurationBuilder
public FileBasedConfigurationBuilder(final Class<? extends T> resCls)
From source file:org.powertac.common.config.Configurator.java
public final static PropertiesConfiguration readProperties(String path) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().fileBased().setBasePath(".").setFileName(path) .setLocationStrategy(fileLocationStrategy).setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();/*from ww w. j a v a2 s. co m*/ }
From source file:org.powertac.common.config.Configurator.java
public final static PropertiesConfiguration readProperties(URL url) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().fileBased().setURL(url).setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();/* w w w . j av a 2 s . co m*/ }
From source file:org.powertac.common.config.Configurator.java
public final static PropertiesConfiguration readProperties(File file) throws ConfigurationException { return new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().fileBased().setFile(file).setLocationStrategy(fileLocationStrategy) .setListDelimiterHandler(listDelimiterHandler)) .getConfiguration();//from w w w.j av a 2 s .c o m }
From source file:org.sdw.util.ConfigReader.java
/** * Single parameter constructor//w ww .j ava 2 s .c o m * @param propertyFile : Absolute/ Relative path of property file to be read */ public ConfigReader(String propertyFile) { Parameters params = new Parameters(); builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class); builder.configure(params.properties().setFileName(propertyFile) .setListDelimiterHandler(new DefaultListDelimiterHandler(','))); }
From source file:org.talend.dataprep.encrypt.PropertiesEncryption.java
/** * Applies the specified function to the specified set of parameters contained in the input file. * * @param input The specified name of file to encrypt * @param mustBeModified the specified set of parameters * @param function the specified function to apply to the set of specified parameters */// w w w . j av a2 s.c o m private void modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function) { Path inputFilePath = Paths.get(input); if (Files.exists(inputFilePath) && Files.isRegularFile(inputFilePath) && Files.isReadable(inputFilePath)) { try { Parameters params = new Parameters(); FileBasedConfigurationBuilder<PropertiesConfiguration> builder = // new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) // .configure(params.fileBased() // .setFile(inputFilePath.toFile())); // PropertiesConfiguration config = builder.getConfiguration(); for (String key : mustBeModified) { config.setProperty(key, function.apply(config.getString(key))); } builder.save(); } catch (ConfigurationException e) { LOGGER.error("unable to read {} {}", input, e); } } else { LOGGER.debug("No readable file at {}", input); } }