code: public static void cleanUpDir(final File dir) {
      try {
        if (dir != null && dir.exists()) {
          FileUtils.deleteDirectory(dir);
        }
      } catch (final IOException e) {
        logger.error("Failed to delete the directory", e);
        dir.deleteOnExit();
      }
    }
docs: Clean up the directory.
  
  @param dir the directory to be deleted