📜  Java.util.ResourceBundle类

📅  最后修改于: 2020-11-14 06:22:26             🧑  作者: Mango


介绍

java.util.ResourceBundle类包含特定于语言环境的对象。以下是有关ResourceBundle的要点-

  • 该类使您可以编写可以轻松本地化或翻译成不同语言的程序。

  • 此类程序一次处理多个语言环境,以后可以轻松修改以支持更多语言环境。

  • Java平台提供ResourceBundle的两个子类,即ListResourceBundle和PropertyResourceBundle。

类声明

以下是java.util.ResourceBundle类的声明-

public abstract class ResourceBundle
   extends Object

领域

以下是java.util.ResourceBundle类的字段-

protected ResourceBundle parent-这是此捆绑包的父捆绑包。

类的构造函数

Sr.No. Constructor & Description
1

ResourceBundle()

This is the single constructor.

类方法

Sr.No. Method & Description
1 static void clearCache()

This method removes all resource bundles from the cache that have been loaded using the caller’s class loader.

2 static void clearCache(ClassLoader loader)

This method removes all resource bundles from the cache that have been loaded using the given class loader.

3 boolean containsKey(String key)

This method determines whether the given key is contained in this ResourceBundle or its parent bundles.

4 static ResourceBundle getBundle(String baseName)

This method 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)

This method 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)

This method gets a resource bundle using the specified base name, locale, and class loader.

7 static ResourceBundle getBundle(String baseName, Locale targetLocale, ClassLoader loader, ResourceBundle.Control control)

This method Returns a resource bundle using the specified base name, target locale, class loader and control.

8 static ResourceBundle getBundle(String baseName, Locale targetLocale, ResourceBundle.Control control)

This method returns a resource bundle using the specified base name, target locale and control, and the caller’s class loader.

9 static ResourceBundle getBundle(String baseName, ResourceBundle.Control control)

This method returns a resource bundle using the specified base name, the default locale and the specified control.

10 abstract Enumeration getKeys()

This method returns an enumeration of the keys.

11 Locale getLocale()

This method returns the locale of this resource bundle.

12 Object getObject(String key)

This method gets an object for the given key from this resource bundle or one of its parents.

13 String getString(String key)

This method gets a string for the given key from this resource bundle or one of its parents.

14 String[] getStringArray(String key)

This method gets a string array for the given key from this resource bundle or one of its parents.

15 protected abstract Object handleGetObject(String key)

This method gets an object for the given key from this resource bundle.

16 protected Set handleKeySet()

This method queries if the given date is in daylight savings time in this time zone.

17 Set keySet()

This method returns a Set of all keys contained in this ResourceBundle and its parent bundles.

18 protected void setParent(ResourceBundle parent)

This method sets the parent bundle of this bundle.

方法继承

此类从以下类继承方法-

  • java.util.Object