java怎么获取当前路径

lewis 2017-01-14 26次阅读

在Java中,可以使用System.getProperty("user.dir")来获取当前工作目录的路径。示例如下:

public class GetCurrentPath {
    public static void main(String[] args) {
        String currentPath = System.getProperty("user.dir");
        System.out.println("Current working directory is: " + currentPath);
    }
}

运行该程序将会输出当前工作目录的路径。



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。