java(6)获取当前路径

试性不好,多记
public class GetPath {
    public static void main(String[] args) {
        GetPath test = new GetPath();
        System.out.println(test.getPath());
    }

    public String getPath(){
        return this.getClass().getResource("/").getPath();
    }
}

你可能感兴趣的:(java)