package com.zhi.test; public class PathTest {
public static void main(String[] args) {
System.out.println(PathTest.class.getResource(""));
System.out.println(PathTest.class.getResource("/")); System.out.println(PathTest.class.getClassLoader().getResource(""));
System.out.println(PathTest.class.getClassLoader().getResource("/")); System.out.println(ClassLoader.getSystemResource(""));
System.out.println(ClassLoader.getSystemResource("/")); System.out.println(System.getProperty("user.dir"));
}
}
对应数据的路径如下:
file:/E:/workspace/javaee/test/target/test-classes/com/zhi/exportword/
file:/E:/workspace/javaee/test/target/test-classes/
file:/E:/workspace/javaee/test/target/test-classes/
null
file:/E:/workspace/javaee/test/target/test-classes/
null
E:\workspace\javaee\test