1.方法
String path = JDBCUtil.class.getResource("ab.properties")
.getPath();
2.方法
String path = JDBCUtil.class.getClassLoader().getResource(
"com/huigou/dao/ab.properties").getPath();
注意两点:
1.资料文件的路径不同
2.注意URL编码(对空格或中文)编码问题