Example usage for org.apache.commons.configuration2 PropertiesConfiguration setIOFactory

List of usage examples for org.apache.commons.configuration2 PropertiesConfiguration setIOFactory

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 PropertiesConfiguration setIOFactory.

Prototype

public void setIOFactory(final IOFactory ioFactory) 

Source Link

Document

Sets the IOFactory to be used for creating readers and writers when loading or saving this configuration.

Usage

From source file:com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl.java

@Override
public void scrubRegistrationProperties() {
    if (!exist()) {
        return;/* w  w w.  ja  v  a  2s  .  c  o m*/
    }
    try {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setIOFactory(new FilteringOutputWriterFactory());
        PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout();
        layout.setLineSeparator("\n");
        layout.load(config, reader());
        try (FileWriter out = new FileWriter(this.configFile)) {
            layout.save(config, out);
        }
        loadProperties();
    } catch (ConfigurationException | IOException e) {
        LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e);
    }
}