本文整理汇总了Java中org.apache.commons.configuration.PropertiesConfiguration.save方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration.save方法的具体用法?Java PropertiesConfiguration.save怎么用?Java PropertiesConfiguration.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.PropertiesConfiguration
的用法示例。
在下文中一共展示了PropertiesConfiguration.save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveRecord
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public void saveRecord() throws Exception {
if (file.exists()) {
// file.renameTo(new File(Configs.recordFileName+".bak"));
file.delete();
}
file.createNewFile();
PropertiesConfiguration record = new PropertiesConfiguration(
Configs.recordFileName);
record.addProperty("verifiedUsers", Records.verifiedUsers.toArray());
// record.addProperty("records", Records.records);
Object[] usrEntries = Records.records.keySet().toArray();
record.addProperty("usrEntries", usrEntries);
for (Object usr : usrEntries) {
record.addProperty((String) usr, Records.records.get(usr).toArray());
}
record.save();
}
示例2: createDefault
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public void createDefault() throws Exception {
if (file.exists()) {
file.renameTo(new File(Enterence.propFileName + ".bak"));
}
file.createNewFile();
PropertiesConfiguration config = new PropertiesConfiguration(
Enterence.propFileName);
config.setProperty("sudoers", Configs.sudoers);
config.setProperty("sudoPwd", Configs.sudoPwd);
config.setProperty("server", Configs.server);
config.setProperty("name", Configs.name);
config.setProperty("pwd", Configs.pwd);
config.setProperty("channels", Configs.channels);
config.setProperty("preffix", Configs.preffix);
config.setProperty("sudoers", Configs.sudoers);
config.setProperty("recordFileName", Configs.recordFileName);
config.setProperty("useProxy", Configs.useProxy);
config.setProperty("Proxy", Configs.Proxy);
config.save();
}
示例3: normalizeCommands
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
/**
* Normalize all guild commands
* @param collection All commands
* @throws ConfigurationException If apache config throws an exception
*/
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
found.add(new File("resources/guilds/template.properties"));
for (File f : found) {
if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
PropertiesConfiguration config = new PropertiesConfiguration(f);
List<String> enabledCommands = config.getList("EnabledCommands").stream()
.map(object -> Objects.toString(object, null))
.collect(Collectors.toList());
List<String> disabledCommands = config.getList("DisabledCommands").stream()
.map(object -> Objects.toString(object, null))
.collect(Collectors.toList());
for (Command c : collection) {
if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
enabledCommands.add(c.toString());
}
}
config.setProperty("EnabledCommands", enabledCommands);
config.save();
}
}
}
示例4: currentConfig
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
@Override
public synchronized String currentConfig() {
PropertiesConfiguration saver = new PropertiesConfiguration();
StringWriter writer = new StringWriter();
saver.copy(config);
try { saver.save(writer); }
catch (Exception e) {
throw new MetricsConfigException("Error stringify config", e);
}
return writer.toString();
}
示例5: toString
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
static String toString(Configuration c) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
PrintStream ps = new PrintStream(buffer, false, "UTF-8");
PropertiesConfiguration tmp = new PropertiesConfiguration();
tmp.copy(c);
tmp.save(ps);
return buffer.toString("UTF-8");
} catch (Exception e) {
throw new MetricsConfigException(e);
}
}
示例6: dump
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
static void dump(String header, Configuration c, PrintStream out) {
PropertiesConfiguration p = new PropertiesConfiguration();
p.copy(c);
if (header != null) {
out.println(header);
}
try { p.save(out); }
catch (Exception e) {
throw new RuntimeException("Error saving config", e);
}
}
示例7: save
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public String save() {
// 设定文件初期读入
try {
PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
.getContextClassLoader().getResource("language/package.properties"));
languageConf.setProperty(YiDuConfig.TITLE, Utils.escapePropterties(title));
languageConf.setProperty(YiDuConfig.SITEKEYWORDS, Utils.escapePropterties(siteKeywords));
languageConf.setProperty(YiDuConfig.SITEDESCRIPTION, Utils.escapePropterties(siteDescription));
languageConf.setProperty(YiDuConfig.NAME, Utils.escapePropterties(name));
languageConf.setProperty(YiDuConfig.URL, Utils.escapePropterties(url));
languageConf.setProperty(YiDuConfig.COPYRIGHT, Utils.escapePropterties(copyright));
languageConf.setProperty(YiDuConfig.BEIANNO, Utils.escapePropterties(beianNo));
languageConf.setProperty(YiDuConfig.ANALYTICSCODE, Utils.escapePropterties(analyticscode));
languageConf.setProperty(YiDuConfig.CATEGORY, Utils.escapePropterties(category));
File languageFile = new File(languageConf.getPath());
OutputStream out = new FileOutputStream(languageFile);
languageConf.save(out);
} catch (Exception e) {
addActionError(e.getMessage());
logger.error(e);
return ADMIN_ERROR;
}
loadData();
addActionMessage(getText("messages.save.success"));
return INPUT;
}
示例8: createDefault
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
public void createDefault() throws Exception {
if (file.exists()) {
// file.renameTo(new File(Configs.recordFileName+".bak"));
file.delete();
}
file.createNewFile();
PropertiesConfiguration record = new PropertiesConfiguration(
Configs.recordFileName);
Records.mutedUsers.add("foo_-_");
Records.records.put("foo_-_", new HashSet<String>() {
{
this.add("test");
}
});
Records.verifiedUsers.add("d0048");
record.addProperty("verifiedUsers", Records.verifiedUsers.toArray());
// record.addProperty("records", Records.records);
Object[] usrEntries = Records.records.keySet().toArray();
record.addProperty("usrEntries", usrEntries);
for (Object usr : usrEntries) {
record.addProperty((String) usr, Records.records.get(usr).toArray());
}
record.save();
}
示例9: setUserValues
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
private void setUserValues(String propName, String propValue){
try {
PropertiesConfiguration config = new PropertiesConfiguration(extFolder+propFileName);
config.setProperty(propName, propValue);
config.save();
//logger.info(config.getPath());
} catch (Exception e) {
logger(logger,"error", e.getMessage());
}
}
示例10: loadData
import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类
@Override
protected void loadData() {
if (StringUtils.isEmpty(uv)) {
addActionError(getText("errors.not.exsits.upgradeVersion"));
return;
}
// step1下载安装包并解压缩
logger.info("going to download upgrade file : " + uv + ".zip");
ZIP_FILE_URL = SITE_URL + uv + ".zip";
String currentPath = UpgradeAction.class.getClassLoader().getResource("").getPath();
File f = new File(currentPath).getParentFile().getParentFile();
INPUT_ZIP_FILE = f.getAbsolutePath() + File.separator + "tmp" + File.separator + uv + ".zip";
OUTPUT_FOLDER = f.getAbsolutePath() + File.separator + "tmp" + File.separator + uv + File.separator;
BASE_FOLDER = f.getAbsolutePath() + File.separator;
downloadFile();
if (this.hasErrors()) {
return;
}
logger.info("going to unzip upgrade file : " + uv + ".zip");
unZipFile();
if (this.hasErrors()) {
return;
}
// 读取rules文件
String content = readFileByLines(OUTPUT_FOLDER + "rule");
Gson g = new Gson();
List<UpgradeBean> upgradeList = g.fromJson(content, new TypeToken<List<UpgradeBean>>() {
}.getType());
for (UpgradeBean rb : upgradeList) {
switch (rb.getType()) {
case FileType.STATIC:
case FileType.CLASS:
case FileType.FTL:
case FileType.JSP:
case FileType.XML:
// 替换或添加静态文件,class文件,ftl,jsp
// 直接覆盖
File srcFile = new File(OUTPUT_FOLDER + rb.getPath());
File destFile = new File(BASE_FOLDER + rb.getPath());
try {
FileUtils.copyFile(srcFile, destFile);
} catch (IOException e1) {
// TODO Auto-generated catch block
logger.error(e1.getMessage(), e1);
addActionError(e1.getMessage());
return;
}
break;
case FileType.PROPERTIES:
// 修改properties文件
try {
PropertiesConfiguration propertiesFile = new PropertiesConfiguration(Thread.currentThread().getContextClassLoader()
.getResource(rb.getFileName()));
propertiesFile.setProperty(rb.getKey(), rb.getContent());
File jdbcFile = new File(propertiesFile.getPath());
OutputStream out = new FileOutputStream(jdbcFile);
propertiesFile.save(out);
} catch (Exception e) {
addActionError(e.getMessage());
logger.error(e);
}
break;
case FileType.SQL:
// 执行文件
upgradeService.excuteUpgradeSql(rb.getSql());
break;
default:
break;
}
}
}