扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

java怎么获取当前路径

扬州沐宇科技
2024-02-29 13:56:47
Java

在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);

}

}

```

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

扫码添加客服微信