初始化Properties对象,load properties文件:

private static final Properties MESSAGERESOURCES = new Properties();

static {
try {
MESSAGERESOURCES.load(ClassLoader.getSystemResourceAsStream("/messages.properties"));
MessageFormat.format("", "");
} catch (IOException e) {
mylogger.error("Error >>>> : Could not load error message resource file 'message.properties'", e);
}
}

message.properties 文件内容:

ERROR_MESSAGE = test product number is {0}, the env {1} can not do this.

格式化message信息:

String para[] = {"1001", "dev_1"};
String message = MessageFormat.format(MESSAGERESOURCES.getProperty(“ERROR_MESSAGE”, para);

得到的Message信息为:

test product number is 1001, the env dev_1 can not do this.

最新文章

  1. iar调试
  2. touches
  3. HTML中表单提交数据GET、POST的区别
  4. javascript实现数据结构与算法系列:功能完整的线性链表
  5. T-SQL游标
  6. 论文阅读(2014-1)----a new collaborative filtering-based recommender system for manufacturing appstore: which applications would be useful to your busines?
  7. linux和windows双系统导致的时间日
  8. MySQL新建用户,授权,删除用户,修改密码等命令
  9. linux重要目录说明
  10. hdu_4547_CD操作(在线LCA)
  11. __x__(47)0910第六天__IE6到IE11对于包含中文路径的png显示问题
  12. zabbix监控实战<1>
  13. nginx-2-nginx的反向代理
  14. python 全栈开发,Day7(元组转换,列表以及字典的坑,集合,关系测试,深浅copy,编码补充)
  15. centos7.2 开机启动脚本
  16. R语言—统计结果输出至本地文件方法总结
  17. 文档碎片及xml讲解
  18. Bing Developer Assistant开发随记
  19. 【基于EF Core的Code First模式的DotNetCore快速开发框架】完成对DB First代码生成的支持
  20. webElement.text()获取到内容为空

热门文章

  1. win7下的iis配置
  2. Java学习笔记--HashMap中使用object做key的问题【转】
  3. Mac实用技巧
  4. cf E. Valera and Queries
  5. cf E. Dima and Magic Guitar
  6. cf437D The Child and Zoo
  7. 奔五的人学IOS:swift练手与csdn,最近学习总结
  8. Linux内核设计基础(十)之内核开发与总结
  9. linux系统下怎么安装.deb文件?
  10. hdfs经常使用命令