已知Message.properties文件中有一组key-value属性:
key = {0} is not found!
从该配置文件中读取键值为key的字符串,可以用ResourceBundle方法:
String key = "key";
ResourceBundle resource= PropertyResourceBundle.getBundle("Message");
String result = resource.getString(key);
MessageFormat ft= new MessageFormat(result);
ft.format(result, "file");
输出结果:
file is not found!