Java.util.ResourceBundle Class
Java ResourceBundle Class
Java.util package provides a ResourceBundle class which contain locale-specific objects. When a program needs a locale-specific resource, a String for example, the program can load it from the resource bundle that is appropriate for the current user's locale. In this way, program code can be written in a way which is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles. This allows to write programs that can:
- be easily localized, or translated, into different languages.
- handle multiple locales at once.
- be easily modified later to support even more locales.
Class declaration
The declaration of java.util.ResourceBundle class is:
public abstract class ResourceBundle extends Object
Fields
S.N | Fields & Description |
---|---|
1. |
protected ResourceBundle parent The parent bundle of this bundle. |
Class Constructors
S.N | Constructors & Description |
---|---|
1. |
ResourceBundle() Sole constructor. |
java.util.ResourceBundle Methods
The java.util.ResourceBundle class has a number of methods which are listed below:
Member Methods
S.N | Methods & Description |
---|---|
1. |
static void clearCache() Removes all resource bundles from the cache that have been loaded using the caller's class loader. |
2. |
static void clearCache(ClassLoader loader) Removes all resource bundles from the cache that have been loaded using the given class loader. |
3. |
boolean containsKey(String key) Determines whether the given key is contained in this ResourceBundle or its parent bundles. |
4. |
static ResourceBundle getBundle(String baseName) Gets a resource bundle using the specified base name, the default locale, and the caller's class loader. |
5. |
static ResourceBundle getBundle(String baseName, Locale locale) Gets a resource bundle using the specified base name and locale, and the caller's class loader. |
6. |
static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader) Gets a resource bundle using the specified base name, locale, and class loader. |
7. |
abstract Enumeration<String> getKeys() Returns an enumeration of the keys. |
8. |
Locale getLocale() Returns the locale of this resource bundle. |
9. |
Object getObject(String key) Gets an object for the given key from this resource bundle or one of its parents. |
10. |
String getString(String key) Gets a string for the given key from this resource bundle or one of its parents. |
Methods inherited
This class inherits the methods of following class:
- java.lang.Object