java中如何获得当前路径
在Java中,可使用`System.getProperty("user.dir")`来获得当前工作目录的路径。
示例代码以下:
```java
public class Main {
public static void main(String[] args) {
String currentPath = System.getProperty("user.dir");
System.out.println("当前路径:" + currentPath);
}
}
```
运行以上代码,将输出当前工作目录的路径。
TOP