本文整理汇总了Java中org.apache.commons.configuration.PropertiesConfiguration.load方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration.load方法的具体用法?Java PropertiesConfiguration.load怎么用?Java PropertiesConfiguration.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.PropertiesConfiguration
的用法示例。
在下文中一共展示了PropertiesConfiguration.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PropertyFileModifier
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public PropertyFileModifier(File propertiesFile) throws ConfigurationException
{
this.file = propertiesFile;
props = new PropertiesConfiguration();
props.setLayout(new ExtendedPropertiesLayout(props));
props.setEncoding("UTF-8");
props.setDelimiterParsingDisabled(true);
if( file.exists() )
{
props.load(file);
}
}
示例2: getConfiguration
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
private Configuration getConfiguration(String name) {
Configuration configuration = null;
URL url = Thread.currentThread().getContextClassLoader().getResource(name);
if (url != null) {
PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setURL(url);
// Set reloading strategy
String dynamicReload = ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload", null);
if (dynamicReload!=null && dynamicReload.equalsIgnoreCase("true")) {
long refreshDelay = Constants.getPositiveInteger(
ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload_interval"), 15000 );
FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
strategy.setRefreshDelay(refreshDelay);
pc.setReloadingStrategy(strategy);
pc.addConfigurationListener(new MessageResourcesCfgListener(pc.getBasePath()));
}
try {
pc.load();
configuration = pc;
} catch (ConfigurationException e) {
Debug.error("Message Resources configuration exception: " + e.getMessage());
}
}
return configuration;
}
示例3: loadProperties
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public boolean loadProperties() {
try (FileInputStream finput = new FileInputStream("resources/Bot.properties")) {
PropertiesConfiguration config = new PropertiesConfiguration();
config.load(finput, "UTF-8");
config.setEncoding("UTF-8");
botConfig.setToken(config.getString("BotToken"));
botConfig.setAvatar(config.getString("Avatar"));
botConfig.setBotOwnerId(config.getLong("BotOwnerId", 0));
botConfig.setBotInviteLink(config.getString("InviteLink"));
botConfig.setMaxSongLength(config.getInt("MaxSongLength", 15));
botConfig.setCompanionBot(config.getBoolean("MusicCompanion", false));
botConfig.setDefaultSSLPort(config.getInt("DefaultSSLPort", 8443));
botConfig.setDefaultInsecurePort(config.getInt("DefaultInsecurePort", 8080));
Configuration subset = config.subset("apikey");
Iterator<String> iter = subset.getKeys();
while(iter.hasNext()) {
String key = iter.next();
String val = subset.getString(key);
if(val.length() > 0) {
this.apiKeys.put(key, val);
logger.info("Added API key for: {}", key);
}
}
StatusChangeJob.setStatuses(config.getStringArray("StatusRotation"));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例4: E2EConfigLoader
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public E2EConfigLoader(String defaultFileName) {
String fileName = getFileNameFromVmOptions();
if (fileName == null) {
fileName = defaultFileName;
}
PropertiesConfiguration propCfg = new PropertiesConfiguration();
try {
propCfg.load(getClass().getClassLoader().getResourceAsStream(fileName));
} catch (Exception e) {
log.error("Failed to load " + fileName, e);
}
config = propCfg;
}