Java读取WEB-INF目录下的properties配置文件

文件位置:

 

代码:

public static Properties getProperties(){   
        Properties pts = new Properties ();
        FileInputStream in = null;
        try{
            String path = UtilManager.class.getResource("/").getPath();
            String websiteURL = (path.replace("/build/classes", "").replace("%20"," ").replace("classes/", "") + "wsdl.properties").replaceFirst("/", "");
            System.out.println ("websiteURL:"+websiteURL);
            in = new FileInputStream(websiteURL);
            pts.load(in);
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
        }
        return pts;
    }

 

 

posted @ 2015-08-12 15:18  大漠神驼  阅读(811)  评论(0编辑  收藏  举报