USE A PROPERTIES FILE It's often useful to provide a simple way to set values for your application in a text file that can be read at startup for configuration or preference information, such as JDBC connection parameters. The Properties class provides a simple way to do so while taking care of much of the I/O and parsing code for you. A Properties file is just a simple text file that contains name/value pairs of strings separated by an equals sign, one per line. You can create a Properties file manually or programmatically and modify the properties in it while your application is running to save changes. You do need to know where to find the file and what it is named, so establishing a standard location for placing the files is a prerequisite. Creating a Properties object from an existing file is simple: Properties myProperties = new Properties(); FileInputStream source = new FileInputStream("propertiesFileName"); //provide the correct file name or path here myProperties.load(source); source.close(); Once you have a Properties object, you can obtain values, set values, enumerate keys or values, etc. using normal HashTable methods. Note, however, that while HashTable will allow setting any object as a key or value, you should only pass String objects as keys or values to a Properties object. You can keep type safety in your code by always using the setProperty() method to change or add values as that method only accepts Strings. A useful function of a Properties object is the ability to set default entries separately from the actual entries. This enables you to have a default Properties file as well as a custom file that overrides the defaults. If you request a value for a key that does not exist in the standard Properties HashMap, the default HashMap is automatically searched for a matching key. For example, if the myProperties object created above is to be used as the default property set, you can add an overriding set of values with this code: Properties userProps = new Properties(myProperties); propSource = new FileInputStream("overrideProperties"); userProps.load(propSource); propSource.close(); If you now use the userProps object instead of myProperties, the settings from the overrideProperties file will be returned in preference to those from the propertiesFileName file. Finally, you can update the Properties file with any changes by using the store() method. (Note that this example stores the overriding values from the overrideProperties file plus any changes made by the application, not the default values from the propertiesFileName file.) FileOutputStream propFile = new FileOutputStream("overrideProperties"); userProps.store(propFile, "a Comment"); propFile.close(); While there are more robust ways to store and retrieve configuration information (JDBC, JNDI), Properties is a quick and simple method that is accessible to users and minimizes the dependency of your application on outside services. -------------------------------------------