您的位置:宽带测速网 > 编程知识 > java怎么获取当前路径

java怎么获取当前路径

2025-06-14 09:02来源:互联网 [ ]

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

public class GetCurrentPath {public static void main(String[] args) {String currentPath = System.getProperty("user.dir");System.out.println("Current working directory is: " + currentPath);}}

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