码迷,mamicode.com
首页 > 其他好文 > 详细

加载Properties配置文件

时间:2017-09-18 17:25:23      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:inf   substr   try   get   nts   style   new   source   bst   

/** 
     * 加载Properties配置文件
     * 
     * @author ZhangHaiNing
     * @param file 要读取的文件 
     * @return
     */
    public static Properties getProp(String file){
            Properties prop=new Properties();
        try {
            String url = TelChargeDwr.class.getResource("").getPath().replaceAll("%20", " ");    
            String path = url.substring(0, url.indexOf("WEB-INF")) + "WEB-INF/";      
            prop.load(new FileInputStream(path+file)); 
        } catch (IOException e) {
            e.printStackTrace();
        }
        return prop;
    }

 

加载Properties配置文件

标签:inf   substr   try   get   nts   style   new   source   bst   

原文地址:http://www.cnblogs.com/zhncnblogs/p/7543610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!