ResourceBundle.Control.NewBundle Method

Definition

Instantiates a resource bundle for the given bundle name of the given format and locale, using the given class loader if necessary.

[Android.Runtime.Register("newBundle", "(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/String;Ljava/lang/ClassLoader;Z)Ljava/util/ResourceBundle;", "GetNewBundle_Ljava_lang_String_Ljava_util_Locale_Ljava_lang_String_Ljava_lang_ClassLoader_ZHandler")]
public virtual Java.Util.ResourceBundle NewBundle (string baseName, Java.Util.Locale locale, string format, Java.Lang.ClassLoader loader, bool reload);
[<Android.Runtime.Register("newBundle", "(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/String;Ljava/lang/ClassLoader;Z)Ljava/util/ResourceBundle;", "GetNewBundle_Ljava_lang_String_Ljava_util_Locale_Ljava_lang_String_Ljava_lang_ClassLoader_ZHandler")>]
abstract member NewBundle : string * Java.Util.Locale * string * Java.Lang.ClassLoader * bool -> Java.Util.ResourceBundle
override this.NewBundle : string * Java.Util.Locale * string * Java.Lang.ClassLoader * bool -> Java.Util.ResourceBundle

Parameters

baseName
String

the base bundle name of the resource bundle, a fully qualified class name

locale
Locale

the locale for which the resource bundle should be instantiated

format
String

the resource bundle format to be loaded

loader
ClassLoader

the ClassLoader to use to load the bundle

reload
Boolean

the flag to indicate bundle reloading; true if reloading an expired resource bundle, false otherwise

Returns

the resource bundle instance, or null if none could be found.

Attributes

Exceptions

if we can not access resources

if we can not instantiate a resource class

if other I/O exception happens

Remarks

Instantiates a resource bundle for the given bundle name of the given format and locale, using the given class loader if necessary. This method returns null if there is no resource bundle available for the given parameters. If a resource bundle can't be instantiated due to an unexpected error, the error must be reported by throwing an Error or Exception rather than simply returning null.

If the reload flag is true, it indicates that this method is being called because the previously loaded resource bundle has expired.

The default implementation instantiates a ResourceBundle as follows.

<ul>

<li>The bundle name is obtained by calling #toBundleName(String, Locale) toBundleName(baseName, locale).</li>

<li>If format is "java.class", the Class specified by the bundle name is loaded with the given class loader. If the Class is found and accessible then the ResourceBundle is instantiated. The resource bundle is accessible if the package of the bundle class file is open unconditionally; otherwise, IllegalAccessException will be thrown. Note that the reload flag is ignored for loading class-based resource bundles in this default implementation. </li>

<li>If format is "java.properties", #toResourceName(String, String) toResourceName(bundlename, "properties") is called to get the resource name. If reload is true, ClassLoader#getResource(String) load.getResource is called to get a URL for creating a URLConnection. This URLConnection is used to URLConnection#setUseCaches(boolean) disable the caches of the underlying resource loading layers, and to URLConnection#getInputStream() get an <code>InputStream</code>. Otherwise, ClassLoader#getResourceAsStream(String) loader.getResourceAsStream is called to get an InputStream. Then, a PropertyResourceBundle is constructed with the InputStream.</li>

<li>If format is neither "java.class" nor "java.properties", an IllegalArgumentException is thrown.</li>

</ul>

Java documentation for java.util.ResourceBundle.Control.newBundle(java.lang.String, java.util.Locale, java.lang.String, java.lang.ClassLoader, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to