Java Reference
In-Depth Information
> javac -d . structure/PrefsDemo.java
> java structure.PrefsDemo
lucida-bright
lucida-blackletter
<preferences EXTERNAL_XML_VERSION="1.0">>
<root type="user">>
<map/>>
<node name="structure">>
<map>>
<entry key="displayFontName" value="helvetica"/>>
<entry key="textFontName" value="times-roman"/>>
</map>>
<node name="a">>
<map/>>
<node name="b">>
<map>>
<entry key="meaning" value="42"/>>
<entry key="pi" value="3.141592653589793"/>>
</map>>
</node>>
</node>>
</node>>
</root>>
</preferences>
On subsequent runs, it finds and returns the “user provided” settings (I've elided the XML
output from the second run, because most of the XML output is the same):
> java structure.PrefsDemo
times-roman
helvetica
...
>
Properties
The Properties class is similar to a HashMap or Hashtable (it extends the latter), but with
methods defined specifically for string storage and retrieval and for loading/saving. Proper-
ties objects are used throughout Java, for everything from setting the platform font names
to customizing user applications into different Locale settings as part of internationalization
and localization. When stored on disk, a Properties object looks just like a series of
name=value assignments, with optional comments. Comments are added when you edit a
Search WWH ::




Custom Search