this.getClass().getResourceAsStream("src/test.properties")为什么null值
File file=new File("src/properties");
if(!file.exists()){
file.mkdirs();
}
file=new File("src/properties/test.properties");
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
另外,如果我想让properties文件不存在就自动在src下面创建该怎么写的。。
[解决办法]
getResourceAsStream的参数使用:
有 /,/代表代表了工程的根目录
没有 /,代表当前类的目录 ,运行环境下当然没有src目录了