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