关于读取properties文件路径问题

 1 1.方法一 
 2 InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream(“init.properties”)
 3 
 4 2.方法二(要求TestProperties和init.properties在同一目录下) 
 5 InputStream fis =TestProperties.class.getResourceAsStream(“init.properties”)
 6 
 7 3.方法三,对于Web工程也可以这样。 
 8 先获取ServletContext,然后 
 9 
10 InputStream in=context.getResourceAsStream(“/WEB-INF/classes/init.properties”);

 

posted @ 2018-08-15 11:35  1109159477  阅读(1255)  评论(0编辑  收藏  举报