Java Reference
In-Depth Information
24.2.2. PropertyResourceBundle
PropertyResourceBundle is a subclass of ResourceBundle that reads its list of
resources from a text property description. Instead of using an array of
key/resource pairs, the text contains key/resource pairs as lines of the
form
key=value
Both keys and values must be strings. A PropertyResourceBundle object
reads the text from an InputStream passed to the PropertyResourceBundle
constructor and uses the information it reads to build a lookup table for
efficient access.
The bundle search process that we described earlier actually has an
additional step that looks for a file ResName .properties after it looks
for a class ResName . For example, if the search process doesn't find
the class GlobalRes_eo_KI_left it will then look for the file Glob-
alRes_eo_KI_left.properties before looking for the next resources class.
If that file exists, an input stream is created for it and used to construct
a PropertyResourceBundle that will read the properties from the file.
It is easier to use property files than to create subclasses of ListRe-
sourceBundle but the files have two limitations. First, they can only define
string resources whereas ListResourceBundle can define arbitrary objects.
Second, the only legal character encoding for property files is the byte
format of ISO 8859-1. This means that other Unicode characters must
be encoded with \u xxxx escape sequences.
24.2.3. Subclassing ResourceBundle
ListResourceBundle , PropertyResourceBundle , and .properties files will be
sufficient for most of your bundles, but you can create your own sub-
 
Search WWH ::




Custom Search