public static String ensureTrailingSlash(final String path) {
    if ((path == null) || path.equals("")) {
      return "";
    }

    final StringBuilder buf = new StringBuilder(path);
    while (buf.charAt(buf.length() - 1) == File.separatorChar) {
      buf.deleteCharAt(buf.length() - 1);
    }
    return buf.append(File.separatorChar).toString();
  }
Returns a copy of the specified String with a trailing path separator. This method ensures that
there are no duplicate trailing separators.

@param path the path to ensure a trailing separator for
@return the copied String or an empty String if path is null or empty.
java/zylib/src/main/java/com/google/security/zynamics/zylib/io/FileUtils.java