File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 41489
    
  53
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?


Ping & DNS - my free Android networking tools app
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://aspose.com/file-tools
 
subject: how can i read from properties every thing start with foo.* ?