java - How to read indexed properties with Apache Commons Configuration - Stack Overflow

The Apache Commons Configuration Java library can easily read repeated properties as lists andor array

The Apache Commons Configuration Java library can easily read repeated properties as lists and/or arrays.

How can I read indexed properties?

Repeated properties

Sample code from the Commons Configuration user guide.

usergui.properties file:

colors.pie = #FF0000
colors.pie = #00FF00
colors.pie = #0000FF

Java code:

Configurations configs = new Configurations();
PropertiesConfiguration config = configs.properties("usergui.properties");

List<String> list = config.getList(String.class, "colors.pie"));
String[] array = config.getStringArray("colors.pie")));

The list and array variables will both contain [#FF0000, #00FF00, #0000FF].

Indexed properties

usergui.properties file:

colors.pie.0 = #FF0000
colors.pie.1 = #00FF00
colors.pie.2 = #0000FF

Is there a way I can use Commons Configuration to read these properties as a list and/or an array?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745635413a4637362.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信