brokencolor

获取项目根路径(一)

File files = new File("");
String filePath = files.getCanonicalPath();
System.out.println("filePath: " + filePath);

在项目开发中展示的路径: filePath: /home/idea/project/java_basic
在项目打成jar包中的路径: filePath: /home/idea/project/java_basic/selfimpr-fileupload/target

获取项目根路径(二)

String filePath = System.getProperty("user.dir");
System.out.println("filePath: " + filePath);

在项目开发中展示的路径: filePath: /home/idea/project/java_basic
在项目打成jar包中的路径: filePath: /home/idea/project/java_basic/selfimpr-fileupload/target

参考地址:https://www.jianshu.com/p/1c9714622a4f

 

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2021-11-27
  • 2021-11-29
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2022-01-07
  • 2021-12-10
猜你喜欢
  • 2021-11-29
  • 2021-11-29
  • 2021-11-28
  • 2021-09-27
  • 2021-11-30
相关资源
相似解决方案