java.lang.Object | |||
↳ | java.util.Dictionary <K, V> | ||
↳ | java.util.Hashtable <K, V> | ||
↳ | java.util.Properties |
Known Direct Subclasses |
Known Indirect Subclasses |
A
Properties
object is a
Hashtable
where the keys and values
must be
String
s. Each property can have a default
Properties
list which specifies the default
values to be used when a given key is not found in this
Properties
instance.
Character Encoding
Note that in some cases
Properties
uses ISO-8859-1 instead of UTF-8.
ISO-8859-1 is only capable of representing a tiny subset of Unicode.
Use either the
loadFromXML
/
storeToXML
methods (which use UTF-8 by
default) or the
load
/
store
overloads that take
an
OutputStreamWriter
(so you can supply a UTF-8 instance) instead.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
defaults |
The default values for keys not found in this
Properties
instance.
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Constructs a new
Properties
object.
|
||||||||||
|
Constructs a new
Properties
object using the specified default
Properties
.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Searches for the property with the specified name.
|
||||||||||
|
Searches for the property with the specified name.
|
||||||||||
|
Lists the mappings in this
Properties
to
out
in a human-readable form.
|
||||||||||
|
Lists the mappings in this
Properties
to
out
in a human-readable form.
|
||||||||||
|
Loads properties from the specified
InputStream
, assumed to be ISO-8859-1.
|
||||||||||
|
Loads properties from the specified
Reader
.
|
||||||||||
|
Loads the properties from an
InputStream
containing the
properties in XML form.
|
||||||||||
|
Returns all of the property names (keys) in this
Properties
object.
|
||||||||||
|
This method was deprecated
in API level 1.
This method ignores any
IOException
thrown while
writing — use
store(OutputStream, String)
instead for better exception
handling.
|
||||||||||
|
Maps the specified key to the specified value.
|
||||||||||
|
Stores properties to the specified
OutputStream
, using ISO-8859-1.
|
||||||||||
|
Stores the mappings in this
Properties
object to
out
,
putting the specified comment at the beginning.
|
||||||||||
|
Writes all properties stored in this instance into the
OutputStream
in XML representation.
|
||||||||||
|
Writes all properties stored in this instance into the
OutputStream
in XML representation.
|
||||||||||
|
Returns those property names (keys) in this
Properties
object for which
both key and value are strings.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.Hashtable
|
|||||||||||
From class
java.util.Dictionary
|
|||||||||||
From class
java.lang.Object
|
|||||||||||
From interface
java.util.Map
|
The default values for keys not found in this
Properties
instance.
Constructs a new
Properties
object using the specified default
Properties
.
properties |
the default
Properties
.
|
---|
Searches for the property with the specified name. If the property is not
found, it looks in the default
Properties
. If the property is not
found in the default
Properties
, it returns the specified
default.
name | the name of the property to find. |
---|---|
defaultValue | the default value. |
Searches for the property with the specified name. If the property is not
found, the default
Properties
are checked. If the property is not
found in the default
Properties
,
null
is returned.
name | the name of the property to find. |
---|
null
if it can't be found.
Lists the mappings in this
Properties
to
out
in a human-readable form.
Note that values are truncated to 37 characters, so this method is rarely useful.
Lists the mappings in this
Properties
to
out
in a human-readable form.
Note that values are truncated to 37 characters, so this method is rarely useful.
Loads properties from the specified
InputStream
, assumed to be ISO-8859-1.
See "
Character Encoding
".
in |
the
InputStream
|
---|
IOException |
---|
Loads properties from the specified
Reader
.
The properties file is interpreted according to the following rules:
in |
the
Reader
|
---|
IOException | |
IOException |
Loads the properties from an
InputStream
containing the
properties in XML form. The XML document must begin with (and conform to)
following DOCTYPE:
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">Also the content of the XML data must satisfy the DTD but the xml is not validated against it. The DTD is not loaded from the SYSTEM ID. After this method returns the InputStream is not closed.
in | the InputStream containing the XML document. |
---|
IOException | in case an error occurs during a read operation. |
---|---|
InvalidPropertiesFormatException | if the XML data is not a valid properties file. |
Returns all of the property names (keys) in this
Properties
object.
This method was deprecated
in API level 1.
This method ignores any
IOException
thrown while
writing — use
store(OutputStream, String)
instead for better exception
handling.
Saves the mappings in this
Properties
to the specified
OutputStream
, putting the specified comment at the beginning. The output
from this method is suitable for being read by the
load(InputStream)
method.
out |
the
OutputStream
to write to.
|
---|---|
comment | the comment to add at the beginning. |
ClassCastException | if the key or value of a mapping is not a String. |
---|
Maps the specified key to the specified value. If the key already exists,
the old value is replaced. The key and value cannot be
null
.
name | the key. |
---|---|
value | the value. |
null
.
Stores properties to the specified
OutputStream
, using ISO-8859-1.
See "
Character Encoding
".
out |
the
OutputStream
|
---|---|
comment | an optional comment to be written, or null |
IOException | |
ClassCastException | if a key or value is not a string |
IOException |
Stores the mappings in this
Properties
object to
out
,
putting the specified comment at the beginning.
writer |
the
Writer
|
---|---|
comment | an optional comment to be written, or null |
IOException | |
ClassCastException | if a key or value is not a string |
IOException |
Writes all properties stored in this instance into the
OutputStream
in XML representation. The DOCTYPE is
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">If the comment is null, no comment is added to the output. The parameter
encoding
defines which encoding should be used. The
OutputStream
is not closed at the end.
os |
the
OutputStream
to write to.
|
---|---|
comment | the comment to add. If null, no comment is added. |
encoding |
the code identifying the encoding that should be used to
write into the
OutputStream
.
|
IOException | if an error occurs during writing to the output. |
---|
Writes all properties stored in this instance into the
OutputStream
in XML representation. The DOCTYPE is
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">If the comment is null, no comment is added to the output. UTF-8 is used as the encoding. The
OutputStream
is not closed at the end. A
call to this method is the same as a call to
storeToXML(os,
comment, "UTF-8")
.
os |
the
OutputStream
to write to.
|
---|---|
comment | the comment to add. If null, no comment is added. |
IOException | if an error occurs during writing to the output. |
---|
Returns those property names (keys) in this
Properties
object for which
both key and value are strings.