java获取资源路径
在web项目中:
Thread.currentThread().getContextClassLoader().getResource("")
file:/D:/apache-tomcat-6.0.26/webapps/myweb/WEB-INF/classes/
BundleConfig.class.getClassLoader().getResource("")
file:/D:/apache-tomcat-6.0.26/webapps/myweb/WEB-INF/classes/
ClassLoader.getSystemResource("")
null
BundleConfig.class.getResource("")
file:/D:/apache-tomcat-6.0.26/webapps/myweb/WEB-INF/classes/com/resource/
BundleConfig.class.getResource("/")
file:/D:/apache-tomcat-6.0.26/webapps/CountemywebCenter/WEB-INF/classes/
new File("/").getAbsolutePath()
D:\
System.getProperty("user.dir")
D:\apache-tomcat-6.0.26\bin
Thread.currentThread().getContextClassLoader().getResource("./")
file:/D:/apache-tomcat-6.0.26/lib/
在java项目中:
Thread.currentThread().getContextClassLoader().getResource("")
file:/D:/work/worksapce_mall/MyTest/bin/
BundleConfig.class.getClassLoader().getResource("")
file:/D:/work/worksapce_mall/MyTest/bin/
ClassLoader.getSystemResource("")
file:/D:/work/worksapce_mall/MyTest/bin/
BundleConfig.class.getResource("")
file:/D:/work/worksapce_mall/MyTest/bin/strings/
BundleConfig.class.getResource("/")
file:/D:/work/worksapce_mall/MyTest/bin/
new File("/").getAbsolutePath()
D:\
System.getProperty("user.dir")
D:\work\worksapce_mall\MyTest
Thread.currentThread().getContextClassLoader().getResource("./")
file:/D:/work/worksapce_mall/MyTest/bin/