Name
Properties
Synopsis
This
class is an extension of Hashtable that allows
key/value pairs to be read from and written to a stream. The
Properties class implements the system properties
list, which supports user customization by allowing programs to look
up the values of named resources. Because the load(
) and store( ) methods provide an easy
way to read and write properties from and to a text stream, this
class provides a convenient way to implement an application
configuration file.
When you create a Properties object, you may
specify another Properties object that contains
default values. Keys (property names) and values are associated in a
Properties object with the
Hashtable method put( ). Values
are looked up with getProperty( ); if this method
does not find the key
in the
current Properties object, it looks in the default
Properties object that was passed to the
constructor method. A default value can also be specified, in case
the key is not found at all. Use setProperty( ) to
add a property name/value pair to the Properties
object. This Java 1.2 method is preferred over the inherited
put( ) method because it enforces the constraint
that property names and values be strings.
propertyNames( ) returns an
enumeration of all property names (keys) stored in the
Properties object and (recursively) all property
names stored in the default Properties object
associated with it. list( ) prints the properties
stored in a Properties object, which can be useful for debugging. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access