public static void delete(File folder){
  if (folder.isDirectory()) {
    File[] contents=folder.listFiles();
    for (    File file : contents) {
      FileUtils.delete(file);
    }
    folder.delete();
  }
 else {
    folder.delete();
  }
}

public static void delete ( File folder ) { if ( folder . isDirectory ( ) ) { File [ ] contents = folder . listFiles ( ) ; for ( File file : contents ) { FileUtils . delete ( file ) ; } folder . delete ( ) ; } else { folder . delete ( ) ; } }
cleans a given file . if the file is a directory , it first cleans all its contained files ( or folders ) .
