dyh-air

//获取跟目录

String pathPrefix = ResourceUtils.getURL("classpath:").getPath();
File file = new File(pathPrefix);
if(!file.exists()) file = new File("");
System.out.println("file path:"+file.getAbsolutePath());

//获取文件可以直接如下

//File file = new File("classpath: static/images/test.png");

//如果上传目录为/static/images/upload/,则可以如下获取:
File upload = new File(file.getAbsolutePath(),"static/images/upload/");
if(!upload.exists()) upload.mkdirs();
System.out.println("upload url:"+upload.getAbsolutePath());
//在开发测试模式时,得到的地址为:{项目跟目录}/target/static/images/upload/

 

分类:

技术点:

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2021-11-19
  • 2021-08-09
  • 2021-11-19
  • 2021-08-21
  • 2022-02-04
相关资源
相似解决方案