Answer the question
In order to leave comments, you need to log in
How to get a list of properties with the same level?
Hello, please help me answer the following question.
There is a familiar application.property file. It stores properties in the following form:
propLevel1.data1
propLevel1.data2
propLevel2.data1
propLevel2.data2
How can you get a list of properties that start with propLevel1.* without "extra blood"? Most likely, there are already ready-made solutions that I cannot find.
Answer the question
In order to leave comments, you need to log in
If these are Java properties, and we use Java 8, then you can try this
Properties props = new Properties() //как-то в общем мы получили сей объект, это не важно
List<String> vals = props.stringPropertyNames().stream().filter(key -> key.startWith("propLevel1")).map(props::getProperty).collect(Collectors.toList());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question