File对象 判断文件是否存在是否是文件夹

String Path = request.getSession().getServletContext().getRealPath("/");
          
          String path = Path+"QRCerweima";  
          File folder = new File(path);
          //文件夹路径不存在
          if (!folder.exists() && !folder.isDirectory()) {
              System.out.println("文件夹路径不存在,创建路径:" + path);
              folder.mkdirs();
          }

猜你喜欢

转载自blog.csdn.net/m0_38053538/article/details/81127081