Given a language code of fr and a country code of FR, which file name represents a resource bundle file name that is not the default?
A.
MessageBundle_fr_FR.properties
B.
MessageBundle_fr_FR.profile
C.
MessageBundle_fr_FR.xinl
D.
MessageBundle__fr__FR.Java
E.
MessageBundle__fr__FR.Locale
Explanation:
The default file is MessageBundle.properties. The non-default file name is MessageBundle_fr_FR.propertiesNote 0:.properties is a file extension for files mainly used in Java related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles. Each parameter is stored as a pair of strings, one storing the name of the parameter (called the key), and the other storing the value.
Note 1:You can obtain an instance of ResourceBundle by calling its static getBundle method.
public static ResourceBundle getBundle(java.lang.String baseName) public static ResourceBundle getBundle(java.lang.String baseName, Locale locale) For example:
ResourceBundle rb = ResourceBundle.getBundle(“MyResources”, Locale.US); This will load the ResourceBundle object with the values in the corresponding properties file.
1.If a suitable properties file is not found, the ResourceBundle object will use the default properties file, which will be the one whose name equals the base name and has the properties extension. In this case, the default file would be MyResources.properties. 2.If this file is not found, a java.util.MissingResourceException will be thrown.
Note2:java.util.ResourceBundle class enables you to choose and read the properties file specific to the user’s locale and look up the values.
A ResourceBundle object has a base name. In order for a ResourceBundle object to pick up a properties file, the filename must be composed of the ResourceBundle base name, followed by an underscore, followed by the language code, and optionally followed by another underscore and the country code.
The format for the properties file name is as follows:
basename_languageCode_countryCode
For example, suppose the base name is MyResources and you define the following three locales:US-en
DE-de
CN-zh
Then you would have these three properties files:MyResources_en_US.properties
MyResources_de_DE.properties
MyResources_zh_CN.propertiesReference:Reading Properties Files using ResourceBundle
A