code: public static void deleteDirRecursive(File dir) throws IOException {
          File failed = deleteDirRecursiveInternal(dir, true);
          if (failed != null) {
              throw new IOException("Could not delete file: " + failed.getPath());
          }
      }
docs: Deletes all files within the given directory recursively (including subdirectories).
  This method fails fast with an IOException on the first file that could not be deleted.