Package java.util Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Properties

Fields , Constructors , Methods

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.


Fields


defaults

protected Properties defaults 

A property list which contains contains default values for any keys not found in this property list.


Constructors


Properties

public Properties() 

Creates an empty property list with no default values.


Properties

public Properties(Properties  defaults) 

Creates an empty property list with the specified defaults.

ParameterDescription
defaults the defaults


Methods


getProperty

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.

ParameterDescription
key the property key


getProperty

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.

ParameterDescription
key the hashtable key
defaultValue a default value


list

public void list(PrintStream  out) 

Prints this property list out to the specified output stream. This method is useful for debugging.

ParameterDescription
out an output stream


load

public void load(InputStream  in) 
throws IOException 

Reads a property list from an input stream.

ParameterDescription
in the input stream

Throw:

IOException

If an error occurred when reading from the input stream.


propertyNames

public Enumeration propertyNames() 

Return Value:

Returns An enumeration of all the keys in this property list, including the keys in the default property list .


save

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.

ParameterDescription
out an output stream
header a description of the property list



Top© 1996 Sun Microsystems, Inc. All rights reserved.