public static String appendUri(final String baseUri, String path, final boolean escapeDoubleSlash) {
        String resultUri = baseUri;
        if (path != null && path.length() > 0) {
            if (path.startsWith("/")) {
                // trim the trailing slash in baseUri, since the path already starts with a slash
                if (resultUri.endsWith("/")) {
                    resultUri = resultUri.substring(0, resultUri.length() - 1);
                }
            } else if (!resultUri.endsWith("/")) {
                resultUri += "/";
            }
            if (escapeDoubleSlash) {
                resultUri += path.replace("//", "/%2F");
            } else {
                resultUri += path;
            }
        } else if (!resultUri.endsWith("/")) {
            resultUri += "/";
        }

        return resultUri;
    }
Append the given path to the given baseUri.

@param baseUri The URI to append to (required, may be relative)
@param path The path to append (may be null or empty).  Path should be pre-encoded.
@param escapeDoubleSlash Whether double-slash in the path should be escaped to "/%2F"
@return The baseUri with the path appended
aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java