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

时间:2015-08-12 16:14:21   收藏:0   阅读:330

文件位置:

技术分享

 

代码:

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;
    }

 

 

技术分享

原文:http://www.cnblogs.com/staryy/p/4724480.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!