aspose file tools
The moose likes Beginning Java and the fly likes how can i read from properties every thing start with foo.* ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how can i read from properties every thing start with foo.* ?" Watch "how can i read from properties every thing start with foo.* ?" New topic
Author

how can i read from properties every thing start with foo.* ?

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello all
i have big properties file that i use it as configuration file
there is section in my application that uses only some portion of the properties file this
properties are set into Properties class

all the key's that start with foo.*
for example
...
foo.name
foo.age
foo.lastname
....

how can i set my Properties class with only keys that start with foo? and not the others?
the getProperty("foo.*") dont work....
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
i meant with ResourceBundle
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35252
    
    7
What does it matter how big the file is (and what other properties it contains), as long as the application knows which ones to use?


Android appsImageJ pluginsJava web charts
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
well i want to keep it generic

so i could add different configurations keys based on the foo.* whiteout changing the code

so in code i will know that the Properties object im building will be set from all the keys starting with foo.*
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
There is a getKeys() method. Could you iterate the keys and match on startsWith or a RegEx or something?

I need to look into this myself. I copied some code years ago that requires tags with sequence numbers, eg foo1, foo2, foo3, etc. I iterate through numbers until I get a not found. Ick.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how can i read from properties every thing start with foo.* ?
 
Similar Threads
File Class
nested java maps
How to set system properties permanently?
can I set the path in my code to refer a properties file?
"JAVA_HOME/bin"... Directory help