java.util
public class: PropertyResourceBundle [javadoc |
source]
java.lang.Object
java.util.ResourceBundle
java.util.PropertyResourceBundle
{@code PropertyResourceBundle} loads resources from an {@code InputStream}. All resources are
Strings. The resources must be of the form {@code key=value}, one
resource per line (see Properties).
| Field Summary |
|---|
| Properties | resources | |
| Constructor: |
public PropertyResourceBundle(InputStream stream) throws IOException {
if( null == stream ) {
throw new NullPointerException();
}
resources = new Properties();
resources.load(stream);
}
Constructs a new instance of {@code PropertyResourceBundle} and loads the
properties file from the specified {@code InputStream}. Parameters:
stream -
the {@code InputStream}.
Throws:
IOException -
if an error occurs during a read operation on the
{@code InputStream}.
|
public PropertyResourceBundle(Reader reader) throws IOException {
resources = new Properties();
resources.load(reader);
}
Constructs a new instance of PropertyResourceBundle and loads the
properties from the reader. Parameters:
reader -
the input reader
Throws:
IOException -
- since:
1.6 -
|
| Methods from java.util.ResourceBundle: |
|---|
|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getKeys, getLocale, getObject, getString, getStringArray, handleGetObject, handleKeySet, keySet, setParent |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.util.PropertyResourceBundle Detail: |
public Enumeration<String> getKeys() {
if (parent == null) {
return getLocalKeys();
}
return new Enumeration< String >() {
Enumeration< String > local = getLocalKeys();
Enumeration< String > pEnum = parent.getKeys();
String nextElement;
private boolean findNext() {
if (nextElement != null) {
return true;
}
while (pEnum.hasMoreElements()) {
String next = pEnum.nextElement();
if (!resources.containsKey(next)) {
nextElement = next;
return true;
}
}
return false;
}
public boolean hasMoreElements() {
if (local.hasMoreElements()) {
return true;
}
return findNext();
}
public String nextElement() {
if (local.hasMoreElements()) {
return local.nextElement();
}
if (findNext()) {
String result = nextElement;
nextElement = null;
return result;
}
// Cause an exception
return pEnum.nextElement();
}
};
}
Answers the names of the resources contained in this
PropertyResourceBundle. |
public Object handleGetObject(String key) {
return resources.get(key);
}
Answers the named resource from this PropertyResourceBundle, or null if
the resource is not found. |
protected Set<String> handleKeySet() {
return resources.stringPropertyNames();
}
Answers a set of the keys in this ResourceBundle but not in its parents. |