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