最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin9PV0评论

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?

Post a comment

comment list (0)

  1. No comments so far