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
posted 13 years ago
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.
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.