java中当前路径 相对路径

public class FilePath {
  public void Print() {
   String a = this.getClass().getClassLoader().getResource(".").getPath();
   String b = this.getClass().getResource("").getPath();
   String c = this.getClass().getResource(" ").getPath();
   String d = this.getClass().getResource("/").getPath();
   String e = System.getProperty("user.dir");
   System.out.println(a);
   System.out.println(b);
   System.out.println(c);
   System.out.println(d);
   System.out.println(e);
  
  }

  public static void main(String[] args) {
   FilePath f = new FilePath();
   f.Print();
  }
 }

你可能感兴趣的:(java中当前路径 相对路径)