public void save()

in src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java [722:758]


    public void save(final PropertiesConfiguration config, final Writer writer) throws ConfigurationException {
        try {
            @SuppressWarnings("resource") // createPropertiesReader wraps the writer.
            final PropertiesConfiguration.PropertiesWriter propWriter = config.getIOFactory().createPropertiesWriter(writer, config.getListDelimiterHandler());
            propWriter.setGlobalSeparator(getGlobalSeparator());
            if (getLineSeparator() != null) {
                propWriter.setLineSeparator(getLineSeparator());
            }
            if (headerComment != null) {
                writeComment(propWriter, getCanonicalHeaderComment(true));
            }
            boolean firstKey = true;
            for (final String key : getKeys()) {
                if (config.containsKeyInternal(key)) {
                    // preset header comment needs to be separated from key
                    if (firstKey && headerComment != null && getBlankLinesBefore(key) == 0) {
                        propWriter.writeln(null);
                    }
                    // Output blank lines before property
                    for (int i = 0; i < getBlankLinesBefore(key); i++) {
                        propWriter.writeln(null);
                    }
                    // Output the comment
                    writeComment(propWriter, getCanonicalComment(key, true));
                    // Output the property and its value
                    final boolean singleLine = isForceSingleLine() || isSingleLine(key);
                    propWriter.setCurrentSeparator(getSeparator(key));
                    propWriter.writeProperty(key, config.getPropertyInternal(key), singleLine);
                }
                firstKey = false;
            }
            writeComment(propWriter, getCanonicalFooterCooment(true));
            propWriter.flush();
        } catch (final IOException ioex) {
            throw new ConfigurationException(ioex);
        }
    }