# PropertyResourceBundle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Fields](https://developer.android.com/reference/java/util/PropertyResourceBundle#inhfields)\|[Ctors](https://developer.android.com/reference/java/util/PropertyResourceBundle#pubctors)\|[Methods](https://developer.android.com/reference/java/util/PropertyResourceBundle#pubmethods)\|[Protected Methods](https://developer.android.com/reference/java/util/PropertyResourceBundle#promethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/PropertyResourceBundle#inhmethods)  

# PropertyResourceBundle

`
public


class
PropertyResourceBundle
`  
`


``

extends `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)`


``


`

|---|---|----------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.util.ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle) ||
|   | ↳ | java.util.PropertyResourceBundle |

<br />

*** ** * ** ***

`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](https://developer.android.com/reference/java/util/ResourceBundle)for more information about resource bundles.

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. See[ResourceBundle.getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader))for a complete description of the search and instantiation strategy.

The followingexampleshows a member of a resource bundle family with the base name "MyResources". The text defines the bundle "MyResources_de", the German member of the bundle family. This member is based on`PropertyResourceBundle`, and the text therefore is the content of the file "MyResources_de.properties" (a related[example](https://developer.android.com/reference/java/util/ListResourceBundle#sample)shows how you can add bundles to this family that are implemented as subclasses of`ListResourceBundle`). The keys in this example are of the form "s1" etc. 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.
>
> ```
>  # 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
>  
> ```

|                                                                                                                                                                                                                                                                    ### Inherited fields                                                                                                                                                                                                                                                                    |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.util.ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle) |-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------| | ` protected `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle) | [parent](https://developer.android.com/reference/java/util/ResourceBundle#parent) The parent bundle of this bundle. | |

|                                                                                                                                                                      ### Public constructors                                                                                                                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[PropertyResourceBundle](https://developer.android.com/reference/java/util/PropertyResourceBundle#PropertyResourceBundle(java.io.InputStream))`(`[InputStream](https://developer.android.com/reference/java/io/InputStream)` stream) ` Creates a property resource bundle from an[InputStream](https://developer.android.com/reference/java/io/InputStream). |
| ` `[PropertyResourceBundle](https://developer.android.com/reference/java/util/PropertyResourceBundle#PropertyResourceBundle(java.io.Reader))`(`[Reader](https://developer.android.com/reference/java/io/Reader)` reader) ` Creates a property resource bundle from a[Reader](https://developer.android.com/reference/java/io/Reader).                           |

|                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getKeys](https://developer.android.com/reference/java/util/PropertyResourceBundle#getKeys())`() ` Returns an`Enumeration`of the keys contained in this`ResourceBundle`and its parent bundles.                                                                         |
| ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                   | ` `[handleGetObject](https://developer.android.com/reference/java/util/PropertyResourceBundle#handleGetObject(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Gets an object for the given key from this resource bundle. |

|                                                                                                                                                    ### Protected methods                                                                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[handleKeySet](https://developer.android.com/reference/java/util/PropertyResourceBundle#handleKeySet())`() ` Returns a`Set`of the keys contained*only* in this`ResourceBundle`. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)` ` |------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static final void`                                                                                                                                             | ` `[clearCache](https://developer.android.com/reference/java/util/ResourceBundle#clearCache(java.lang.ClassLoader))`(`[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader)` loader) ` Removes all resource bundles from the cache that have been loaded by the given class loader.                                                                                                                                                                                                                                                                                                                                                                | | ` static final void`                                                                                                                                             | ` `[clearCache](https://developer.android.com/reference/java/util/ResourceBundle#clearCache())`() ` Removes all resource bundles from the cache that have been loaded using the caller's class loader.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                                       | ` `[containsKey](https://developer.android.com/reference/java/util/ResourceBundle#containsKey(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Determines whether the given`key`is contained in this`ResourceBundle`or its parent bundles.                                                                                                                                                                                                                                                                                                                                                                                 | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                            | ` `[getBaseBundleName](https://developer.android.com/reference/java/util/ResourceBundle#getBaseBundleName())`() ` Returns the base name of this bundle, if known, or`null`if unknown.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` static final `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                               | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.Locale,%20java.util.ResourceBundle.Control))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName, `[Locale](https://developer.android.com/reference/java/util/Locale)` targetLocale, `[ResourceBundle.Control](https://developer.android.com/reference/java/util/ResourceBundle.Control)` control) ` Returns a resource bundle using the specified base name, target locale and control, and the caller's class loader.                                                                                                | | ` static final `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                               | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.Locale))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName, `[Locale](https://developer.android.com/reference/java/util/Locale)` locale) ` Gets a resource bundle using the specified base name and locale, and the caller's class loader.                                                                                                                                                                                                                                                                           | | ` static final `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                               | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName) ` Gets a resource bundle using the specified base name, the default locale, and the caller's class loader.                                                                                                                                                                                                                                                                                                                                                                   | | ` static `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                                     | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader,%20java.util.ResourceBundle.Control))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName, `[Locale](https://developer.android.com/reference/java/util/Locale)` targetLocale, `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader)` loader, `[ResourceBundle.Control](https://developer.android.com/reference/java/util/ResourceBundle.Control)` control) ` Returns a resource bundle using the specified base name, target locale, class loader and control. | | ` static `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                                     | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName, `[Locale](https://developer.android.com/reference/java/util/Locale)` locale, `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader)` loader) ` Gets a resource bundle using the specified base name, locale, and class loader.                                                                                                                                                                           | | ` static final `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)                                                               | ` `[getBundle](https://developer.android.com/reference/java/util/ResourceBundle#getBundle(java.lang.String,%20java.util.ResourceBundle.Control))`(`[String](https://developer.android.com/reference/java/lang/String)` baseName, `[ResourceBundle.Control](https://developer.android.com/reference/java/util/ResourceBundle.Control)` control) ` Returns a resource bundle using the specified base name, the default locale and the specified control.                                                                                                                                                                                                                   | | ` abstract `[Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getKeys](https://developer.android.com/reference/java/util/ResourceBundle#getKeys())`() ` Returns an enumeration of the keys.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | ` `[Locale](https://developer.android.com/reference/java/util/Locale)                                                                                            | ` `[getLocale](https://developer.android.com/reference/java/util/ResourceBundle#getLocale())`() ` Returns the locale of this resource bundle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` final `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                      | ` `[getObject](https://developer.android.com/reference/java/util/ResourceBundle#getObject(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Gets an object for the given key from this resource bundle or one of its parents.                                                                                                                                                                                                                                                                                                                                                                                               | | ` final `[String](https://developer.android.com/reference/java/lang/String)                                                                                      | ` `[getString](https://developer.android.com/reference/java/util/ResourceBundle#getString(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Gets a string for the given key from this resource bundle or one of its parents.                                                                                                                                                                                                                                                                                                                                                                                                | | ` final `[String[]](https://developer.android.com/reference/java/lang/String)                                                                                    | ` `[getStringArray](https://developer.android.com/reference/java/util/ResourceBundle#getStringArray(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Gets a string array for the given key from this resource bundle or one of its parents.                                                                                                                                                                                                                                                                                                                                                                                | | ` abstract `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                   | ` `[handleGetObject](https://developer.android.com/reference/java/util/ResourceBundle#handleGetObject(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Gets an object for the given key from this resource bundle.                                                                                                                                                                                                                                                                                                                                                                                                         | | ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>`                          | ` `[handleKeySet](https://developer.android.com/reference/java/util/ResourceBundle#handleKeySet())`() ` Returns a`Set`of the keys contained*only* in this`ResourceBundle`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` `[Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>`                          | ` `[keySet](https://developer.android.com/reference/java/util/ResourceBundle#keySet())`() ` Returns a`Set`of all keys contained in this`ResourceBundle`and its parent bundles.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                          | ` `[setParent](https://developer.android.com/reference/java/util/ResourceBundle#setParent(java.util.ResourceBundle))`(`[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)` parent) ` Sets the parent bundle of this bundle.                                                                                                                                                                                                                                                                                                                                                                                                               | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### PropertyResourceBundle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PropertyResourceBundle (InputStream stream)
```

Creates a property resource bundle from an[InputStream](https://developer.android.com/reference/java/io/InputStream). This constructor reads the property file in UTF-8 by default. If a[MalformedInputException](https://developer.android.com/reference/java/nio/charset/MalformedInputException)or an[UnmappableCharacterException](https://developer.android.com/reference/java/nio/charset/UnmappableCharacterException)occurs on reading the input stream, then the PropertyResourceBundle instance resets to the state before the exception, re-reads the input stream in`ISO-8859-1`and continues reading. If the system property`java.util.PropertyResourceBundle.encoding`is set to either "ISO-8859-1" or "UTF-8", the input stream is solely read in that encoding, and throws the exception if it encounters an invalid sequence. Other encoding values are ignored for this system property. The system property is read and evaluated when initializing this class. Changing or removing the property has no effect after the initialization.

<br />

|                                          Parameters                                          ||
|----------|------------------------------------------------------------------------------------|
| `stream` | `InputStream`: an InputStream that represents a property file to read from. <br /> |

|                                                                                                                              Throws                                                                                                                              ||
|-----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                                            | if an I/O error occurs                                                                                                                    |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)                        | if`stream`is null                                                                                                                         |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)                | if`stream`contains a malformed Unicode escape sequence.                                                                                   |
| [MalformedInputException](https://developer.android.com/reference/java/nio/charset/MalformedInputException)           | if the system property`java.util.PropertyResourceBundle.encoding`is set to "UTF-8" and`stream`contains an invalid UTF-8 byte sequence.    |
| [UnmappableCharacterException](https://developer.android.com/reference/java/nio/charset/UnmappableCharacterException) | if the system property`java.util.PropertyResourceBundle.encoding`is set to "UTF-8" and`stream`contains an unmappable UTF-8 byte sequence. |

### PropertyResourceBundle

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PropertyResourceBundle (Reader reader)
```

Creates a property resource bundle from a[Reader](https://developer.android.com/reference/java/io/Reader). Unlike the constructor[PropertyResourceBundle(InputStream)](https://developer.android.com/reference/java/util/PropertyResourceBundle#PropertyResourceBundle(java.io.InputStream)), there is no limitation as to the encoding of the input property file.

<br />

|                                    Parameters                                     ||
|----------|-------------------------------------------------------------------------|
| `reader` | `Reader`: a Reader that represents a property file to read from. <br /> |

|                                                                                Throws                                                                                ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                             | if an I/O error occurs                                       |
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if`reader`is null                                            |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if a malformed Unicode escape sequence appears from`reader`. |

## Public methods

### getKeys

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Enumeration<String> getKeys ()
```

Returns an`Enumeration`of the keys contained in this`ResourceBundle`and its parent bundles.

<br />

|                                                                                                                     Returns                                                                                                                      ||
|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | an`Enumeration`of the keys contained in this`ResourceBundle`and its parent bundles. <br /> |

**See also:**

- [ResourceBundle.keySet()](https://developer.android.com/reference/java/util/ResourceBundle#keySet())  

### handleGetObject

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object handleGetObject (String key)
```

Gets an object for the given key from this resource bundle. Returns null if this resource bundle does not contain an object for the given key.

<br />

|                       Parameters                       ||
|-------|-------------------------------------------------|
| `key` | `String`: the key for the desired object <br /> |

|                                                     Returns                                                      ||
|--------------------------------------------------------------------|----------------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | the object for the given key, or null <br /> |

## Protected methods

### handleKeySet

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected Set<String> handleKeySet ()
```

Returns a`Set`of the keys contained*only* in this`ResourceBundle`.

<br />

|                                                                                                Returns                                                                                                ||
|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [Set](https://developer.android.com/reference/java/util/Set)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | a`Set`of the keys contained only in this`ResourceBundle` <br /> |

**See also:**

- [ResourceBundle.keySet()](https://developer.android.com/reference/java/util/ResourceBundle#keySet())