Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i meant with ResourceBundle
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic