• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question About Properties File  RSS feed

 
Dave Hewy
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to get a Map object from a properties file?
I have a TreeMap into which I want to load the values from a properties file (using the constructor) without iterating over the list.
Thanks
Dave
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Have you looked at the API docs for java.util.Properties? The Properties class implements the Map interface, so it may do what you want it to do. It actually extends Hashtable, so maybe you're looking for slightly different functionality.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you've loaded a Properties object, you can put the data in a TreeMap( instead using new TreeMap(props) or treeMap.putAll(props). Internally it's going to iterate (what else could it do?) but at least you don't have to cluttur your own code with it.
 
Dave Hewy
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - that's just what I wanted
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!