java中怎么获取当前路径

36次阅读
没有评论

共计 240 个字符,预计需要花费 1 分钟才能阅读完成。

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

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

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

丸趣 TV 网 – 提供最优质的资源集合!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-21发表,共计240字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)