学堂 学堂 学堂公众号手机端

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

lewis 2年前 (2023-12-03) 阅读数 9 #技术

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

publicclassGetCurrentPath{
publicstaticvoidmain(String[]args){
StringcurrentPath=System.getProperty("user.dir");
System.out.println("Currentworkingdirectoryis:"+currentPath);
}
}

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


版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门