code: public static void deletePath(FileSystem fs, Path f, boolean recursive) throws IOException {
      if (fs.exists(f) && !fs.delete(f, recursive)) {
        throw new IOException("Failed to delete: " + f);
      }
    }
docs: A wrapper around {@link FileSystem#delete(Path, boolean)} which throws {@link IOException} if the given
  {@link Path} exists, and {@link FileSystem#delete(Path, boolean)} returns False.