Package java.util |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public class java.util.Properties extends java.util.Hashtable { // Fields protected Properties defaults; // Constructors public Properties(); public Properties(Properties defaults); // Methods public String getProperty(String key); public String getProperty(String key, String defaultValue); public void list(PrintStream out); public void load(InputStream in); public Enumeration propertyNames(); public void save(OutputStream out, String header); }
The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and and its corresponding value in the property list is a string.
A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list.
protected Properties defaultsA property list which contains contains default values for any keys not found in this property list.
public Properties()Creates an empty property list with no default values.
public Properties(Properties defaults)Creates an empty property list with the specified defaults.
Parameter Description defaults the defaults
public String getProperty(String key)Searches for the property with the specified key in this property list.
Return Value:
Returns the value in this property list with the specified key value. If the key is not found in this property list, the default property list , and its defaults, recursively, are then checked. The method returns null if the property is not found.
Parameter Description key the property key
public String getProperty(String key, String defaultValue)Searches for the property with the specified key in this property list.
Return Value:
Returns the value in this property list with the specified key value. If the key is not found in this property list, the default property list , and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.
Parameter Description key the hashtable key defaultValue a default value
public void list(PrintStream out)Prints this property list out to the specified output stream. This method is useful for debugging.
Parameter Description out an output stream
public void load(InputStream in)throws IOExceptionReads a property list from an input stream.
Parameter Description in the input stream Throw:
If an error occurred when reading from the input stream.
public Enumeration propertyNames()Return Value:
Returns An enumeration of all the keys in this property list, including the keys in the default property list .
public void save(OutputStream out, String header)Stores this property list to the specified output stream. The string header is printed as a comment at the beginning of the stream.
Parameter Description out an output stream header a description of the property list