Java获取路径(getResource)

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
上一篇:Derek解读Bytom源码-孤块管理


下一篇:Apache Internal Server Error