ResourceBundle class in JavaThe ResourceBundle class is used to internationalize the messages. In other words, we can say that it provides a mechanism to globalize the messages. The hardcoded message is not considered good in terms of programming, because it differs from one country to another. So we use the ResourceBundle class to globalize the massages. The ResourceBundle class loads these informations from the properties file that contains the messages. Conventionally, the name of the properties file should be filename_languagecode_country code for example MyMessage_en_US.properties. Commonly used methods of ResourceBundle classThere are many methods in the ResourceBundle class. Let's see the commonly used methods of the ResourceBundle class.
Example of ResourceBundle classLet's see the simple example of ResourceBundle class. In this example, we are creating three files:
MessageBundle_en_US.propertiesMessageBundle_in_ID.propertiesInternationalizationDemo.javaOutput:Message in en_US : Hello, how r u? Message in in_ID : halo, apa kabar? Next TopicInternationalizing Date |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India