public static URI addSlash(URI u) throws HiveException {
    if (u.getPath().endsWith("/")) {
      return u;
    }
    try {
      return new URI(u.getScheme(), u.getAuthority(), u.getPath() + "/", u.getQuery(), u.getFragment());
    } catch (URISyntaxException e) {
      throw new HiveException("Could not append slash to a URI", e);
    }
  }
Makes sure, that URI points to directory by adding slash to it.
Useful in relativizing URIs.
ql/src/java/org/apache/hadoop/hive/ql/exec/ArchiveUtils.java