code: static public void delete(Configuration conf, Path src, FileSystem srcFs, boolean recursive,
                        boolean skipTrash, boolean ignoreNonEmpty,
                        boolean onlyDeleteFile) throws IOException {
      FileStatus fs = null;
      try {
        fs = srcFs.getFileStatus(src);
      } catch (FileNotFoundException fnfe) {
        // Have to re-throw so that console output is as expected
        throw new FileNotFoundException("cannot remove "
            + src + ": No such file or directory.");
      }
  
      if (fs.isDir() && !recursive) {
        // We may safely delete empty directories if
        // the recursive option is not specified
        FileStatus children[] = srcFs.listStatus(src);
        if (onlyDeleteFile || (children != null && children.length != 0)) {
          if (ignoreNonEmpty) {
            return;
          } else {
            throw new IOException("Cannot remove directory \"" + src + "\"," +
                " use -rmr instead");
          }
        } else if (children == null) {
          throw new IOException(src + " no longer exists");
        }
      }
  
      if(!skipTrash) {
        try {
          Trash trashTmp = new Trash(srcFs, conf);
          if (trashTmp.moveToTrash(src)) {
            System.err.println("Moved to trash: " + src);
            return;
          }
        } catch (IOException e) {
          Exception cause = (Exception) e.getCause();
          String msg = "";
          if(cause != null) {
            msg = cause.getLocalizedMessage();
          }
          System.err.println("Problem with Trash." + msg +". Consider using -skipTrash option");
          throw e;
        }
      }
  
      if (srcFs.delete(src, recursive, true)) {
        System.err.println("Deleted " + src);
      } else {
        throw new IOException("Delete failed " + src);
      }
    }
docs: /* delete a file