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