天天看点

java 获取classpath路径_java 获取当前classpath的绝对路径

System.out.println("当前类ReadTest.class文件的URI\n" + ReadTest.class.getResource(""));

System.out.println("当前classpath的URI\n" + ReadTest.class.getResource("/"));

System.out.println("当前classpath的URI\n" + ReadTest.class.getClassLoader().getResource(""));

System.out.println("当前classpath的URI\n" + Thread.currentThread().getContextClassLoader().getResource(""));

System.out.println("当前classpath的URI\n" + ClassLoader.getSystemResource(""));

原文:http://www.cnblogs.com/pumushan/p/5630886.html