Reputation: 579
In my project we have a properties file which has some entries as below:
#Data key entries
datakey001
datakey321
datakey451
someotherkey
In fact its not a key value pair, but a list of keys. Using java.util.Properties
I was able to get this using Properties.stringPropertyNames()
.
Now we are migrating to Apache Commons Configuration and I could not find any feature in this library to get all these keys as I used to get previously using java.util.Properties
.
Is there any way in apache commons config by which I can get all these keys without changing the the structure of the properties file?
EDIT: I have tried using Configuration.getKeys()
as below, but the output is empty.
Configuration propertiesConfig = new PropertiesConfiguration("C:\\proj\\myprops.properties");
Iterator<String> it = propertiesConfig.getKeys();
while(it.hasNext()) {
System.out.println(it.next());
}
Upvotes: 4
Views: 3043