以下写法,从class根目录查找文件
Properties properties= new Properties();
InputStream inStream= DBUtil.class.getClassLoader().getResourceAsStream("configjdbc.properties");
properties.load(inStream);
以下写法从当前类所在package下查找文件
Properties properties= new Properties();
InputStream inStream= DBUtil.class.getResourceAsStream("configjdbc.properties");
properties.load(inStream);