code: public static URI setScheme(final URI orig, final String scheme) {
          try {
              return new URI(scheme, orig.getUserInfo(), orig.getHost(), orig.getPort(), orig.getPath(), orig.getQuery(), orig.getFragment());
          } catch (final URISyntaxException e) {
              throw new RuntimeException(e.getMessage(), e);
          }
      }
docs: Create new URI with a given scheme.
  
  @param orig URI to set scheme on
  @param scheme new scheme, {@code null} for no scheme
  @return new URI instance with given path