删除文件夹

解决方案 »

  1.   

      private   void   deleteFolder(File   folder)   {   
              String   childs[]   =   folder.list();   
              if   (childs   ==   null   ||   childs.length   <=   0)   {   
                        folder.delete();   
              }   
              for   (int   i   =   0;   i   <   childs.length;   i++)   {   
                      String   childName   =   childs[i];   
                      String   childPath   =   
                          folder.getPath()   +   File.separator   +   childName;   
                      File   filePath   =   new   File(childPath);   
                      if   (filePath.exists()   &&   filePath.isFile())   {   
                            filePath.delete();   
                      }   
                      else   if   (filePath.exists()   &&   filePath.isDirectory())   {   
                            deleteFolder(filePath);   
                      }   
              }   
        
              folder.delete();   
      }