JAVA获取当前文件路径this.getClass().getResource方法详细讲解
public class Test { public void run() { // TODO Auto-generated method stub System.out.println("测试========》"); String s1=this.getClass().getResource("").getPath(); String s2=this.getClass().getResource("/").getPath(); System.out.println(s1); System.out.println(s2); } public static void main(String[] args) { new Test().run(); } }