code: public static URI replaceScheme(URI uri, String replace, String replacement) {
      if (replace != null && replace.equals(replacement)) {
        return uri;
      }
      try {
        if (replace != null && replace.equals(uri.getScheme())) {
          return new URI(replacement, uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
        } else {
          return uri;
        }
      } catch (URISyntaxException use) {
        throw new RuntimeException("Failed to replace scheme.");
      }
    }
docs: Replace the scheme of the input {@link URI} if it matches the string to replace.