getResource()的使用总结 ;
1.通过ClassLoader来加载getResource()时不需要加 "/" 因为source是从main开始的;
Thread.currentThread().getContextClassLoader().getResource("main/test/test.txt").getPath();
2.通过Class.getResource()来加载文件时需要加“/” classpath 是:/C:/CustomSofter/develop/IDEA/IDEAWorkSpace/C3p0TestPrictice/
String userDir = System.getProperty("user.dir");
print ::::C:\CustomSofter\develop\IDEA\IDEAWorkSpace\C3p0TestPrictice
目录结构:
src/main/test