java.util
Class Properties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
All Implemented Interfaces:
Cloneable, Map, Serializable
Direct Known Subclasses:
Provider
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.

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail.

When saving properties to a stream or loading them from a stream, the ISO 8859-1 character encoding is used. For characters that cannot be directly represented in this encoding, Unicode escapes are used; however, only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.

Since:
JDK1.0
See Also:
native2ascii tool for Solaris, native2ascii tool for Windows, Serialized Form

 

Nested Class Summary

 
Nested classes inherited from class java.util.Map
Map.Entry
 

 

Field Summary

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

 

Constructor Summary

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

 

Method Summary

 String getProperty(String key)
    Searches for the property with the specified key in this property list.
 String getProperty(String key, String defaultValue)
    Searches for the property with the specified key in this property list.
 void list(PrintStream out)
    Prints this property list out to the specified output stream.
 void list(PrintWriter out)
    Prints this property list out to the specified output stream.
 void load(InputStream inStream)
    Reads a property list (key and element pairs) from the input stream.
 Enumeration propertyNames()
    Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.
 void save(OutputStream out, String header)
    Deprecated. This method does not throw an IOException if an I/O error occurs while saving the property list. As of the Java 2 platform v1.2, the preferred way to save a properties list is via the store(OutputStream out, String header) method.
 Object setProperty(String key, String value)
    Calls the Hashtable method put.
 void store(OutputStream out, String header)
    Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable for loading into a Properties table using the load method.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll,