|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.ResourceBundle | +--java.util.PropertyResourceBundle
PropertyResourceBundle
is a concrete subclass of
ResourceBundle
that manages resources for a locale
using a set of static strings from a property file. See
ResourceBundle
for more information about resource
bundles. See Properties
for more information
about properties files, in particular the
information on character encodings.
Unlike other types of resource bundle, you don't subclass
PropertyResourceBundle
. Instead, you supply properties
files containing the resource data. ResourceBundle.getBundle()
will automatically look for the appropriate properties file and create a
PropertyResourceBundle
that refers to it. The resource
bundle name that you pass to ResourceBundle.getBundle()
is
the file name of the properties file, not the class name of the object that
is returned.
For example, if you say ResourceBundle.getBundle("MyResources",
new Locale("fr", "FR"));
the resource bundle lookup mechanism
will search the class path for a file called
MyResources_fr_FR.properties
.
If a real class and a properties file with a particular name both exist, the class wins; the properties file will only be used if there is no class with the desired name.
In the following example, the keys are of the form "s1"... The actual keys are entirely up to your choice, so long as they are the same as the keys you use in your program to retrieve the objects from the bundle. Keys are case-sensitive.
s1=3 s2=MeinDisk s3=3 Mar 96 s4=Der disk '{1}' a {0} a {2}. s5=0 s6=keine Datein s7=1 s8=ein Datei s9=2 s10={0}|3 Datein s11=Der Format worf ein Exception: {0} s12=ERROR s14=Resulte s13=Dialogue s15=Pattern s16=1,3
ResourceBundle
,
ListResourceBundle
,
Properties
Fields inherited from class java.util.ResourceBundle |
parent |
Constructor Summary | |
PropertyResourceBundle(InputStream stream)
Creates a property resource |
Method Summary | |
Enumeration |
getKeys()
Implementation of ResourceBundle.getKeys. |
Object |
handleGetObject(String key)
Override of ResourceBundle, same semantics |
Methods inherited from class java.util.ResourceBundle |
getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, setParent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PropertyResourceBundle(InputStream stream) throws IOException
stream
- property file to read from.Method Detail |
public Object handleGetObject(String key)
handleGetObject
in class ResourceBundle
java.util.ResourceBundle
key
- see class description.NullPointerException
- if key
is
null
.public Enumeration getKeys()
getKeys
in class ResourceBundle
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Oracle and/or its affiliates, in the US and other countries.
Copyright © 1995, 2010 Oracle and/or its affiliates. All rights reserved.