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

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

Introduction

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

Prototype

void save(Writer out) throws ConfigurationException;

Source Link

Document

Save the configuration to the specified writer.

Usage

From source file:openlr.mapviewer.coding.ui.SaveConfigButtonListener.java

@Override
public void actionPerformed(final ActionEvent e) {

    JFileChooser chooser = fileChooserFactory.createFileChooser(FILE_CHOOSER_TOPIC_DECODER_PROPERTIES);
    String codingTypeString = codeOptionsDialog.getCodingType().name().toLowerCase();
    chooser.setDialogTitle("Select the file to save the " + codingTypeString + " properties to");

    int re = chooser.showSaveDialog(codeOptionsDialog);
    if (re == JFileChooser.APPROVE_OPTION) {

        File file = chooser.getSelectedFile();

        if (writePermitted(file)) {

            applyChangesActionListener.applyChanges();

            FileConfiguration currentConfig = codingPropertiesHolder
                    .getProperties(codeOptionsDialog.getCodingType());

            try {

                currentConfig.save(file);

            } catch (ConfigurationException e1) {
                JOptionPane.showMessageDialog(null,
                        "Could not write the properties to file " + file.getAbsolutePath() + ". " + e1,
                        "Write error", JOptionPane.ERROR_MESSAGE);
            }//from w  w w. j  a  va  2  s  .c  o m
        }

    }
}