This week's book giveaway is in the Testing forum. We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line! See this thread for details.
As Jesper suggested, you probably want to look at the java.util.Properties class. It has methods for saving to a .properties file in straight text or XML format. One of the (minor) downsides of Properties is that it extends Hashtable (rather than just wrapping it), so you have direct access to its methods.
Class Properties is an old class, it already existed in Java 1.0, before the time when the collections framework was added to Java (which was in Java 1.2) - that's why it extends the legacy collection class Hashtable. In the current version of Java, it also implements Map<Object, Object>, as the documentation says.
Yes, that's true. However, Map<Object, Object> doesn't really help with type safety. If the designers had chosen to make the Properties class wrap Hashtable instead of extending it, then when generics came along, they could have changed Properties to wrap a Map<String, String>, preserving type safety. Obviously, hindsight is 20/20, but having Hashtable's methods exposed does expose a risk.
expectation is the root of all heartache - shakespeare. tiny ad: