java怎么获取当前路径

1037
2024/3/24 13:56:47
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

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

```java

public class GetCurrentPath {

public static void main(String[] args) {

String currentPath = System.getProperty("user.dir");

System.out.println("Current working directory is: " + currentPath);

}

}

```

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

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: java unsafe类和反射关系