Linux 拨号vps windows公众号手机端

java中怎么获取当前路径

lewis 7年前 (2018-11-19) 阅读数 7 #程序编程
文章标签 Java

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

示例代码如下:

public class Main {
public static void main(String[] args) {
String currentPath = System.getProperty("user.dir");
System.out.println("当前路径:" + currentPath);
}
}

运行以上代码,将输出当前工作目录的路径。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

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

热门