Example usage for org.apache.commons.configuration PropertiesConfiguration save

List of usage examples for org.apache.commons.configuration PropertiesConfiguration save

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration save.

Prototype

public void save(Writer writer) throws ConfigurationException 

Source Link

Document

Save the configuration to the specified stream.

Usage

From source file:org.xwiki.test.integration.utils.XWikiExecutor.java

private void savePropertiesConfiguration(String path, PropertiesConfiguration properties) throws Exception {
    FileOutputStream fos = new FileOutputStream(path);
    try {/*from   w ww.j a  v  a  2  s.c  o  m*/
        properties.save(fos);
    } finally {
        fos.close();
    }
}

From source file:umich.ms.batmass.nbputils.config.BmConfig.java

private static synchronized File getConfigFile(Class<?> clazz) throws IOException, ConfigurationException {
    String filePath = constructConfigFilePath(clazz);
    Path path = Paths.get(filePath);

    // if there was an empty file by that name - it's an artifact from
    // some previous unsuccessful run, so we just delete it
    if (Files.exists(path) && path.toFile().length() == 0) {
        path.toFile().delete();/*w ww.  j a va2 s .  c  om*/
    }

    if (!Files.exists(path)) {
        Files.createDirectories(path.getParent());
        Path createdConfFile = Files.createFile(path);
        //            XMLConfiguration conf = new XMLConfiguration();
        PropertiesConfiguration conf = new PropertiesConfiguration();
        initNewConfiguration(conf, clazz);
        conf.save(createdConfFile.toFile());
    }
    return path.toFile();
}