using properties within the properties file

前端 未结 5 1096
执念已碎
执念已碎 2020-12-17 02:14

I apologize for the title.. i couldn\'t find a better way to explain the situation.

I use to load properties file using a Property class as described in the URL http

5条回答
  •  清歌不尽
    2020-12-17 02:55

    Apache Commons Configuration provides for this: http://commons.apache.org/configuration/

    Simple example code for loading the configuration file:

    Configuration config = new PropertiesConfiguration("config.properties");
    

    You can have 'variable interpolated' properties, as described here http://commons.apache.org/configuration/userguide/howto_basicfeatures.html#Variable_Interpolation

    application.name = Killer App
    application.version = 1.6.2
    
    application.title = ${application.name} ${application.version}
    

    And it also allows you to include other configuration files while you're at it:

    include = colors.properties
    include = sizes.properties
    

    Besides a whole range of other features.

提交回复
热议问题