java文件上传判断文件夹是否存在

判断文件夹是否存在,不存在创建文件夹

  1. File file =new File("E:/workspace/net/src/main/webapp/upload");    
  2. //如果文件夹不存在则创建    
  3. if  (!file .exists()  && !file .isDirectory())      
  4. {       
  5.     System.out.println("//不存在");  
  6.     file .mkdir();    
  7. else   
  8. {  
  9.     System.out.println("//目录存在");  
posted @ 2018-02-02 11:54  三豪  阅读(460)  评论(0编辑  收藏  举报