首先,需要helloFile.properties 文件,里面有 key-value 键值对。
其次,MessageFormat属于java.text.*;
动态传参,具体细节相见MessageFormat.format(String,Object...),仔细看看这个方法。
pulibc static void main(Strings[] args)
{
Localle locale = Local.getDefault();
ResourceBundle bundle = ResourceBundle.getBundle("helloFile",locale);
String value = bundle.getString("hello");
String format = MessageFormat.format(value,new Object[]{"北京"});
}
其次,MessageFormat属于java.text.*;
动态传参,具体细节相见MessageFormat.format(String,Object...),仔细看看这个方法。
pulibc static void main(Strings[] args)
{
Localle locale = Local.getDefault();
ResourceBundle bundle = ResourceBundle.getBundle("helloFile",locale);
String value = bundle.getString("hello");
String format = MessageFormat.format(value,new Object[]{"北京"});
}