日期:2014-05-17  浏览次数:20770 次

getResourceAsStream 读取properties
文件目录如下:
topic
 -src
 -resources
 ---config.properties

resources 已经加入到Build Path 中
程序:System.out.println(Object.class.getResourceAsStream("/resources/config.properties")); 

输出: null

请问如何通过getResourceAsStream读取config.properties
因为要打jar包 想把配置文件独立出来

------解决方案--------------------
resources目录加到build path, "/config.properties"
------解决方案--------------------
web里最好使用 
Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties");

------解决方案--------------------
指定包为同一目录就行了