All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.util.Properties

java.lang.Object
|
   +----java.util.Dictionary
|
           +----java.util.Hashtable
|
                   +----java.util.Properties

public class Properties
extends Hashtable
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 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.


Variable Index

 o defaults
A property list that contains default values for any keys not found in this property list.

Constructor Index

 o Properties()
Creates an empty property list with no default values.
 o Properties(Properties)
Creates an empty property list with the specified defaults.

Method Index

 o getProperty(String)
Searches for the property with the specified key in this property list.
 o getProperty(String, String)
Searches for the property with the specified key in this property list.
 o list(PrintStream)
Prints this property list out to the specified output stream.
 o list(PrintWriter)
Prints this property list out to the specified output stream.
 o load(InputStream)
Reads a property list from an input stream.
 o propertyNames()
Returns an enumeration of all the keys in this property list, including the keys in the default property list.
 o save(OutputStream, String)
Stores this property list to the specified output stream.

Variables

 o defaults
protected Properties defaults
A property list that contains default values for any keys not found in this property list.

Constructors

 o Properties
public Properties()
Creates an empty property list with no default values.

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

Parameters:
defaults - the defaults.

Methods

 o load
public synchronized void load(InputStream in) throws IOException
Reads a property list from an input stream.

Parameters:
in - the input stream.
Throws: IOException
if an error occurred when reading from the input stream.
 o save
public synchronized 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.

Parameters:
out - an output stream.
header - a description of the property list.
 o getProperty
public String getProperty(String key)
Searches for the property with the specified key in this property list. 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.

Parameters:
key - the property key.
Returns:
the value in this property list with the specified key value.
See Also:
defaults
 o getProperty
public String getProperty(String key,
String defaultValue)
Searches for the property with the specified key in this property list. 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.

Parameters:
key - the hashtable key.
defaultValue - a default value.
Returns:
the value in this property list with the specified key value.
See Also:
defaults
 o propertyNames
public Enumeration propertyNames()
Returns an enumeration of all the keys in this property list, including the keys in the default property list.

Returns:
an enumeration of all the keys in this property list, including the keys in the default property list.
See Also:
Enumeration, defaults
 o list
public void list(PrintStream out)
Prints this property list out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.
 o list
public void list(PrintWriter out)
Prints this property list out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.