java代码如下:
public class test {
public static void main(String[] args) throws URISyntaxException {
String path1 = test.class.getResource("/convertFile").getPath();
String path2 = test.class.getResource("/convertFile").toURI().getPath();
String path3 = test.class.getClassLoader().getResource("convertFile").getPath();
String path4= test.class.getClassLoader().getResource("convertFile").toURI().getPath();
System.out.println("path1:"+path1);
System.out.println("path2:"+path2);
System.out.println("path3:"+path3);
System.out.println("path4:"+path4);
}
}
输出结果如下图:
(如有不正确,欢迎纠错)