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