怎么得到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);
System.out.println("*********************");

}


public static void main(String[] args) {

   FilePath  f=new FilePath();
   f.Print();

}
}

这样运行结果如下:
/E:/workspace/WorkFlow/WorkFlow/WebRoot/WEB-INF/classes/
/E:/workspace/WorkFlow/WorkFlow/WebRoot/WEB-INF/classes/com/njusoft/syschroFlow/test/
/E:/workspace/WorkFlow/WorkFlow/WebRoot/WEB-INF/classes/com/njusoft/syschroFlow/test/%20
/E:/workspace/WorkFlow/WorkFlow/WebRoot/WEB-INF/classes/
E:\workspace\WorkFlow\WorkFlow

你可能感兴趣的:(java,C++,c,Web,workflow)