public class Properties
extends java.util.Hashtable
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.
Modified from JDK java.util.Properties to use Reader/Writer as well as InputStream/OutputStream, to fix locale/codepage problems.
Modifier and Type | Field and Description |
---|---|
protected Properties |
defaults
A property list that contains default values for any keys not
found in this property list.
|
Constructor and Description |
---|
Properties()
Creates an empty property list with no default values.
|
Properties(Properties defaults)
Creates an empty property list with the specified defaults.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getProperty(java.lang.String key)
Searches for the property with the specified key in this property list.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Searches for the property with the specified key in this property list.
|
void |
list(java.io.PrintWriter out)
Prints this property list out to the specified output stream.
|
void |
load(java.io.Reader in)
Reads a property list from an input stream.
|
java.util.Enumeration |
propertyNames()
Returns an enumeration of all the keys in this property list, including
the keys in the default property list.
|
void |
save(java.io.Writer out,
java.lang.String header)
Stores this property list to the specified output stream.
|
protected Properties defaults
public Properties()
public Properties(Properties defaults)
defaults
- the defaults.public void load(java.io.Reader in) throws java.io.IOException
in
- the input stream.java.io.IOException
- if an error occurred when reading from the
input stream.public void save(java.io.Writer out, java.lang.String header) throws java.io.IOException
out
- an output stream.header
- a description of the property list.java.io.IOException
public java.lang.String getProperty(java.lang.String key)
null
if the property is not found.key
- the property key.defaults
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
key
- the hashtable key.defaultValue
- a default value.defaults
public java.util.Enumeration propertyNames()
Enumeration
,
defaults
public void list(java.io.PrintWriter out)
out
- an output stream.Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.