CSDN博乐 举荐之美博主趴,帝都先来!【面向专家】极客头条使用体验征文 [张传波]活用UML—打造软件设计高手
java工具类(1)ResourceBundle
分类:java 学习工具类
package com.infofuse.util;import java.util.MissingResourceException;import java.util.ResourceBundle;public class PropertiesUtils {private static final String propertiesFile = "parameter";// 默认绑定资源private static ResourceBundle resources = null;/*** 获取指定属性值* @param property 属性名* @return*/public static String getPropertiesValue(String property) {String val = "";try {if (resources == null) {initResources();}val = resources.getString(property);} catch (Exception e) {// ignore}return val;}/*** 根据配置文件获取指定key值* @param propertiesFile 属性文件* @param property 属性名* @return*/public static String getPropertiesValue(String propertiesFile,String property) {String val = "";ResourceBundle resources1 = null;try {resources1 = ResourceBundle.getBundle(propertiesFile);val = resources1.getString(property);}catch (MissingResourceException e) {// ignore}return val;}/*** 初始化配置文件*/private static void initResources() {try {resources = ResourceBundle.getBundle(propertiesFile);} catch (MissingResourceException e) {throw new RuntimeException(e);}}}
版权声明:本文为博主原创文章,未经博主允许不得转载。
上一篇spring配置定时器的时间设置下一篇计算两个时间戳之间的工作日间隔时间(9:30-12:00 13:00-18.30)
顶0踩0
主题推荐猜你在找
查看评论
* 以上用户言论只代表其个人观点,,不代表CSDN网站的观点或立场
核心技术类目
对人性的弱点有清醒的认识,