java项目如何获取classpath下文件的绝对路径
//1.得到当前项目的classpath的绝对路径的URI表示法。
URL base = Thread.currentThread().getContextClassLoader().getResource("");
//获取 classpath:ehcache/ehcache.xml的绝对路径
String path = new File(base.getFile(), "/ehcache/ehcache.xml").getCanonicalPath();
学习的时候用到了,来记录一下。