Java得到src文件夹下文件的绝对路径
src文件夹是类的根路径
public class Test {
public static void main(String[] args) {
//通过当前线程的类加载器获取
//类根路径下(可多级)文件的绝对路径
String path = Thread.currentThread().getContextClassLoader().getResource("a.txt").getPath();
System.out.println(path);
}
}