javaBean调用同目录下的db.properties文件读不到,为什么?请各位前辈帮忙。
小弟在正在做的jsp项目中写了一个connectionPool类,其中要读入同目录下的
"db.properties"文件(同在web-inf/classes/bst/下,代码在下:
Properties pro = new Properties();
try{
FileInputStream in = new FileInputStream("db.properties");
System.out.println("s");
pro.load(in);
in.close();
}catch(IOException ie){
System.out.println("Can't read db.properties!");
throw new RuntimeException("Can't read db.properties!");
}//end try-catch
结果抛出异常,确定就在
FileInputStream in = new FileInputStream("db.properties");
这一行抛异常,是什么原因?我估计是没有找到同目录下的db.properties文件,是不是“db.properties"路径的写法有问题?