Search code examples
javaconfiguration-filesapache-commons

commons-configuration custom configuration file


I'd to save configuration as a list of sth like: 152.158.1545.415:80 Ok 152.108.145.415:80 152.158.115.415:80 500

instead of:

proxy= 152.108.145.415:80 proxy= 152.108.145.415:80 ... and read it. ( 152.108.145.415 as a string 80 as a number ). Can I do such a customisation in this library (commons-configuration)?


Solution

  • If you are using a PropertiesConfiguration you can customize the layout for the "proxy" property and have the values on a single line like this:

    proxy=152.158.115.415:80,152.158.115.415:80,152.158.115.415:80 
    

    You do this by calling:

    configuration.getLayout().setSingleLine("proxy", true);