public class PropertyResourceBundle extends ResourceBundle
PropertyResourceBundle
是
ResourceBundle
管理资源的地区使用从属性文件的一组静态字符串的具体子类。看到有关资源束的更多信息
ResourceBundle
。
不像其他类型的资源包,你不PropertyResourceBundle
类。相反,您提供包含资源数据的属性文件。ResourceBundle.getBundle
会自动寻找相应的属性文件并创建一个PropertyResourceBundle
指它。看到ResourceBundle.getBundle
为一个完整的描述的搜索和实例化策略。
以下example显示资源束的家庭成员与基地的名字“MyResources”。本文界定了“myresources_de束的束”,家庭成员的德国。这个成员是基于PropertyResourceBundle
,因此是与文本文件“myresources_de内容。属性”(相关example演示如何添加包到这个家庭,为子ListResourceBundle
实现)。在这个例子中的关键是形成“S1”等实际键是完全取决于你的选择,只要是你在你的程序中使用的从束检索对象相同的键。键是区分大小写的。
# MessageFormat pattern s1=Die Platte \"{1}\" enthält {0}. # location of {0} in pattern s2=1 # sample disk name s3=Meine Platte # first ChoiceFormat choice s4=keine Dateien # second ChoiceFormat choice s5=eine Datei # third ChoiceFormat choice s6={0,number} Dateien # sample date s7=3. März 1996
一个PropertyResourceBundle
子类的实现必须是同时被多个线程使用是线程安全的。在这个类中的非抽象方法的默认实现是线程安全的。
注: propertyresourcebundle可以构造从InputStream或Reader,它代表一个属性文件。从InputStream构建propertyresourcebundle实例要求输入流被编码ISO-8859-1。在这种情况下,文字不能代表ISO-8859-1编码必须用Unicode转义为定义在The Java™ Language Specification 3.3节而其他构造函数以读者没有限制。
ResourceBundle
,
ListResourceBundle
,
Properties
ResourceBundle.Control
parent
Constructor and Description |
---|
PropertyResourceBundle(InputStream stream)
创建从一个
InputStream 物业资源包。
|
PropertyResourceBundle(Reader reader)
创建从
Reader 物业资源包。
|
Modifier and Type | Method and Description |
---|---|
Enumeration<String> |
getKeys()
返回包含在这
ResourceBundle 及其父束的关键一
Enumeration 。
|
Object |
handleGetObject(String key)
从这个资源包中获取给定密钥的对象。
|
protected Set<String> |
handleKeySet()
返回一个
Set 的钥匙只有在这
ResourceBundle 。
|
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, keySet, setParent
public PropertyResourceBundle(InputStream stream) throws IOException
InputStream
物业资源包。属性文件的读取与该构造函数必须在ISO-8859-1编码。
stream
- InputStream代表一个属性文件的读取。
IOException
如果I/O错误发生
NullPointerException
-如果
stream
是空的
IllegalArgumentException
-如果
stream
包含一个畸形的Unicode转义序列。
public PropertyResourceBundle(Reader reader) throws IOException
Reader
物业资源包。与构造函数
PropertyResourceBundle(InputStream)
,不局限于输入属性文件的编码是有。
reader
-读者代表一个属性文件的读取。
IOException
如果I/O错误发生
NullPointerException
-如果
reader
是空的
IllegalArgumentException
-如果一个畸形的Unicode转义序列出现在
reader
。
public Object handleGetObject(String key)
ResourceBundle
handleGetObject
方法重写,继承类
ResourceBundle
key
-预期目标的关键
public Enumeration<String> getKeys()
ResourceBundle
及其父束的关键一
Enumeration
。
getKeys
方法重写,继承类
ResourceBundle
ResourceBundle
及其母束中的关键一
Enumeration
。
ResourceBundle.keySet()
protected Set<String> handleKeySet()
Set
的钥匙只有在这
ResourceBundle
。
handleKeySet
方法重写,继承类
ResourceBundle
ResourceBundle
包含
Set
的钥匙
ResourceBundle.keySet()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.