ylliX - Online Advertising Network
Vertex AI - Antrophic and Mistral models: Why does it require Imegen access?

How to read indexed properties with Apache Commons Configuration


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

How can I read indexed 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].

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?



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *