Java IO stream ResourceBundle Read the internationalized resource file

Source: Internet
Author: User
Tags locale

http://www.verejava.com/?id=16994867037422

/** Java.util.ResourceBundle: The contents of the Class (*.properties) resource file used to read the resource file are key=value key-value pairs Note: 1. When reading a resource file based on locale, if A resource file that is defined as basename_language_country.properties is not found and is read from the basename.properties resource file */import Java.util.ResourceB Undle;import Java.util.locale;public class testresourcebundle{public static void Main (string[] args) {//instantiation        A resourcebundle resourcebundle bundle=resourcebundle.getbundle ("message") that reads the resource file;        The corresponding value System.out.println (bundle.getstring ("MSG") is obtained according to Key;        System.out.println ("\ n------------");        Instantiate an American Language object locale locale localeus=new locale ("en", "us");        Read resource files According to locale ResourceBundle bundleus=resourcebundle.getbundle ("message", Localeus);        System.out.println (bundleus.getstring ("MSG"));        Instantiate a Chinese Language object locale locale localecn=new locale ("message", "zh", "CN");        ResourceBundle bundlecn=resourcebundle.getbundle ("message", LOCALECN); System.out.println (BundlEcn.getstring ("MSG")); }}message_zh_cn.properties msg=\u60a8\u597d message_en_us.properties Msg=hello World

http://www.verejava.com/?id=16994867037422

Java IO stream ResourceBundle Read the internationalized resource file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.