code: private static void delete(File file) {
      if (file.isDirectory()) {
        File[] files = file.listFiles();
        if (files != null) {
          for (File child : files) {
            delete(child);
          }
        }
      }
  
      file.delete();
    }
docs: Recursive delete of a file or directory.