首页 > 其他 > 详细

工程中properties文件处理方法类

时间:2016-06-05 15:20:00      阅读:173      评论:0      收藏:0      [点我收藏+]

功能:properties文件加载、取得key对应的值

 1 import java.util.ResourceBundle;
 2 
 3 /**
 4  * 工程中properties文件处理方法类
 5  */
 6 public class ConfigHolder {
 7     private static ResourceBundle bundle;
 8     
 9     /**
10      * 加载properties文件
11      */
12     private static void loadConfig() {
13         if(bundle == null) {
14             // 在class下有config.properties文件,如果在某包下,则如:ort.config
15             bundle = ResourceBundle.getBundle("config");
16         }
17     }
18     
19     /**
20      * 取得properties文件中指定key的值
21      * @param key
22      * @return
23      */
24     public static String getValue(String key) {
25         loadConfig();
26         return bundle.getString(key);
27     }    
28 }

 

工程中properties文件处理方法类

原文:http://www.cnblogs.com/Mr-kevin/p/5560723.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!