public static void cleanDir(File dirToRemove) throws IOException {
  if (dirToRemove.isFile()) {
    FileMisc.forceDelete(dirToRemove);
  }
 else   if (dirToRemove.isDirectory()) {
    try {
      FileUtils.deleteDirectory(dirToRemove);
    }
 catch (    IOException e) {
      for (      File file : FileMisc.list(dirToRemove)) {
        FileMisc.forceDelete(file);
      }
    }
  }
  mkdirs(dirToRemove);
}

public static void cleanDir ( File dirToRemove ) throws IOException { if ( dirToRemove . isFile ( ) ) { FileMisc . forceDelete ( dirToRemove ) ; } else if ( dirToRemove . isDirectory ( ) ) { try { FileUtils . deleteDirectory ( dirToRemove ) ; } catch ( IOException e ) { for ( File file : FileMisc . list ( dirToRemove ) ) { FileMisc . forceDelete ( file ) ; } } } mkdirs ( dirToRemove ) ; }
deletes the given file or directory if it exists , then creates a fresh directory in its place .
