ResourceBunlde 读取property文件内容

来源:互联网 发布:获取python关键字 编辑:程序博客网 时间:2024/06/05 10:09

已知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!

原创粉丝点击