code: public static void deleteDirectories(FileSystem fs, List<String> directoriesToDelete, boolean recursive, boolean moveToTrash) throws IOException {
      for (String directory : directoriesToDelete) {
        if (moveToTrash) {
          moveToTrash(fs, new Path(directory));
        } else {
          deletePath(fs, new Path(directory), recursive);
        }
      }
    }
docs: Calls deletePath() on each directory in the given list of directories to delete.
  If moveToTrash is set, it will be moved to trash according to the file system trash policy.