All Downloads are FREE. Search and download functionalities are using the official Maven repository.

configuration_file_parser.config.ConfigurationLoader Maven / Gradle / Ivy

package configuration_file_parser.config;

import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
import org.apache.commons.configuration2.ex.ConfigurationException;

public class ConfigurationLoader {

    public static Configuration loadConfiguration(String fileName, char delimiter) throws ConfigurationException {
        Parameters params = new Parameters();
        FileBasedConfigurationBuilder builder =
            new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
                .configure(params.properties()
                .setListDelimiterHandler(new DefaultListDelimiterHandler(delimiter))
                .setFileName(fileName));
        return builder.getConfiguration();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy