import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import java.text.MessageFormat;
public class PlaceHolderMsg {

public static void main(String args[])
{
//定义一个Locale变量
Locale currentLocale = null;
//如果运行程序制定了两个参数
if(args.length ==2)
{
//使用运行程序的两个参数构造Locale实例
currentLocale = new Locale(args[0],args[1]);
}
else
{
//否则直接使用系统默认的Locale
currentLocale = Locale.getDefault();
}
//根据Locale加载语言资源
ResourceBundle bundle = ResourceBundle.getBundle("MyResource", currentLocale);
//取得已加载的语言资源文件中msg对应消息
String msg = bundle.getString("msg");
//使用MessageFormat为带占位符的字符串传入参数
System.out.println(MessageFormat.format(msg, "yeeku",new Date()));
}
}
-----------------------------------------------------------------------------------
currentLocale = new Locale(args[0],args[1])是什么意思,;
这里好像就用到currentLocale = Locale.getDefault();
其他我都清楚

解决方案 »

  1.   

    currentLocale = new Locale(args[0],args[1])是什么意思,; 
    这里好像就用到currentLocale = Locale.getDefault(); 你应该先看程序判断:
    1.if(args.length ==2) 
      参数数组长度为2  则执行 currentLocale = new Locale(args[0],args[1])
     可能是设定Local,比如你的浏览器默认的的Local是中文“ZH” ,你要读取英文多语言就要手工设置Locale. 
      currentLocale = new Locale(args[0],args[1]) 就是这个作用
      这个构造参数传什么,你可以看API。2.currentLocale = Locale.getDefault();  获取默认Local,是浏览器来决定的
      点开 工具-Internet选项---常规---语言--  默认Local来至这里的设置。你将英文设置为默认,那么后台获取的就是英文的