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

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

Introduction

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

Prototype

public FileHandler(final FileBased obj) 

Source Link

Document

Creates a new instance of FileHandler and sets the managed FileBased object.

Usage

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   w ww .  j  a  v a 2  s.com
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);
    }
}

From source file:com.heliosdecompiler.helios.Helios.java

private static Configuration loadConfiguration() throws IOException, ConfigurationException {
    Configurations configurations = new Configurations();
    File file = Constants.SETTINGS_FILE_XML;
    if (!file.exists()) {
        XMLConfiguration tempConfiguration = new XMLConfiguration();
        new FileHandler(tempConfiguration).save(file);
    }//from w  ww .  j av  a 2 s.c  o m
    FileBasedConfigurationBuilder<XMLConfiguration> builder = configurations.xmlBuilder(file);
    builder.setAutoSave(true);
    return builder.getConfiguration();
}

From source file:Executable.LinkImputeR.java

private static void writeXML(XMLConfiguration xml, File output) throws OutputException {
    FileHandler handler = new FileHandler(xml);
    try {/*from   www. j  ava2s  .  co m*/
        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);
    }
}