Reputation: 1265
Can we get a property from properties file using some expression. e.g
If I have properties in file like this
user/a/b=active
user/a/c=active
user/a/d=active
Now How can I get all properties which are active. Also Can I get all active using user/a/*
or something like that
Upvotes: 1
Views: 275
Reputation: 57381
The java.util.Properties class has stringPropertyNames() method
you can use the method to iterate all the names and check name and value
Properties prop = new Properties();
// add some properties
prop.put("user/a/b", "active");
prop.put("user/a/c", "active");
prop.put("user/a/d", "active");
// save the Property names in the set
Set<String> set = prop.stringPropertyNames();
for (String name: set) {
if (name.startsWIth("user/a/")) {
//check value and do something
}
}
Upvotes: 1