Example usage for org.apache.commons.configuration2.io FileHandler save

List of usage examples for org.apache.commons.configuration2.io FileHandler save

Introduction

In this page you can find the example usage for org.apache.commons.configuration2.io FileHandler save.

Prototype

private void save(final FileLocator locator) throws ConfigurationException 

Source Link

Document

Internal helper method for saving data to the internal location stored for this object.

Usage

From source file:Executable.LinkImputeR.java

private static void writeXML(XMLConfiguration xml, File output) throws OutputException {
    FileHandler handler = new FileHandler(xml);
    try {/*from   ww w  .ja va2  s . c om*/
        handler.save(output);
    } catch (ConfigurationException ex) {
        if (ex.getCause() instanceof IOException) {
            IOException tex = (IOException) ex.getCause();
            throw new OutputException("Problem writing XML file", tex);
        }
        throw new ProgrammerException(ex);
    }
}

From source file:Executable.Output.java

/**
 * Write the control file (for the final imputation step)
 * @param config The configuration to write
 * @throws OutputException If there is an IO problem
 *///from  ww  w.  j  a  v a2s  .co  m
public void writeControl(List<ImmutableNode> config) throws OutputException {
    BasicConfigurationBuilder<ExtendedXMLConfiguration> builder = new BasicConfigurationBuilder<>(
            ExtendedXMLConfiguration.class).configure(new Parameters().xml());

    ExtendedXMLConfiguration c;
    try {
        c = builder.getConfiguration();
    } catch (ConfigurationException ex) {
        throw new ProgrammerException(ex);
    }

    c.setRootElementName("linkimputepro");

    c.addNodes(null, config);

    FileHandler handler = new FileHandler(c);
    try {
        handler.save(control);
    } catch (ConfigurationException ex) {
        if (ex.getCause() instanceof IOException) {
            IOException tex = (IOException) ex.getCause();
            throw new OutputException("Problem writing imputation control file", tex);
        }
        throw new ProgrammerException(ex);
    }
}