java.util
Class Properties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
All Implemented Interfaces:
Cloneable

public class Properties
extends Hashtable

Persistent properties class. This class is basically a hashtable that can be saved/loaded from a stream. If a property is not found, a property list containing defaults is searched. This allows arbitrary nesting.


Field Summary
protected  Properties defaults
           
 
Constructor Summary
Properties()
          Creates an empty property list.
Properties(Properties defaults)
          Creates an empty property list with specified defaults.
 
Method Summary
 String getProperty(String key)
          Gets a property with the specified key.
 String getProperty(String key, String defaultValue)
          Gets a property with the specified key and default.
 void list(PrintStream out)
          List properties, for debugging
 void load(InputStream in)
          Loads properties from an InputStream.
 Enumeration propertyNames()
          Enumerates all the keys.
 void save(OutputStream out, String header)
          Save properties to an OutputStream.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, elements, get, isEmpty, keys, put, rehash, remove, size, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaults

protected Properties defaults
Constructor Detail

Properties

public Properties()
Creates an empty property list.


Properties

public Properties(Properties defaults)
Creates an empty property list with specified defaults.

Parameters:
defaults - the defaults
Method Detail

load

public void load(InputStream in)
          throws IOException
Loads properties from an InputStream.

Parameters:
in - the input stream
Throws:
IOException - Error when reading from input stream.

save

public void save(OutputStream out,
                 String header)
Save properties to an OutputStream. Use the header as a comment at the top of the file.


getProperty

public String getProperty(String key)
Gets a property with the specified key. If the key is not found in this property list, tries the defaults. This method returns null if the property is not found.

Parameters:
key - the hashtable key

getProperty

public String getProperty(String key,
                          String defaultValue)
Gets a property with the specified key and default. If the key is not found in this property list, tries the defaults. This method returns defaultValue if the property is not found.


propertyNames

public Enumeration propertyNames()
Enumerates all the keys.


list

public void list(PrintStream out)
List properties, for debugging