@GetMapping("/lujing")
    public void getLujing() throws Exception{
        //当前项目下路径
        File file = new File("");
        String filePath = file.getCanonicalPath();
        System.out.println(filePath);

        //当前项目下xml文件夹
        File file1 = new File("");
        String filePath1 = file1.getCanonicalPath()+File.separator+"xml\\";
        System.out.println(filePath1);

        //获取类加载的根路径
        File file3 = new File(this.getClass().getResource("/upload").getPath());
        System.out.println(file3.getPath());

        //获取当前类的所在工程路径
        File file4 = new File(this.getClass().getResource("").getPath());
        System.out.println(file4);

        //获取所有的类路径 包括jar包的路径
        System.out.println(System.getProperty("java.class.path"));
    }

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-12-19
  • 2021-08-16
  • 2021-06-06
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2021-10-04
  • 2021-12-09
  • 2021-07-03
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案