读书人

java向properties资料传动态参数

发布时间: 2012-11-04 10:42:41 作者: rapoo

java向properties文件传动态参数
首先,需要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[]{"北京"});
}

读书人网 >编程

热点推荐