code: private static void rmDir(File dir) {
          for (File file: dir.listFiles()) {
              if (file.isDirectory()) {
                  rmDir(file);
              } else {
                  if (!file.delete()) {
                      logger.warn("Can't delete file " + file);
                  }
              }
          }
          if (!dir.delete()) {
              logger.warn("Can't delete dir " + dir);
          }
      }
docs: recursively remove a directory, logging warnings if needed.