1. 程式人生 > >加載Properties配置文件

加載Properties配置文件

rep auth sta ini 加載 repl index new nts

/** 
     * 加載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配置文件