code: public static URI buildUri(final String host, final int port, final String path,
        final boolean isHttp, final Pair<String, String>... params) throws IOException {
      final URIBuilder builder = new URIBuilder();
      builder.setScheme(isHttp ? "http" : "https").setHost(host).setPort(port);
  
      if (null != path && path.length() > 0) {
        builder.setPath(path);
      }
  
      if (params != null) {
        for (final Pair<String, String> pair : params) {
          builder.setParameter(pair.getFirst(), pair.getSecond());
        }
      }
  
      try {
        return builder.build();
      } catch (final URISyntaxException e) {
        throw new IOException(e);
      }
    }
docs: helper function to build a valid URI.
  
  @param host host name.
  @param port host port.
  @param path extra path after host.
  @param isHttp indicates if whether Http or HTTPS should be used.
  @param params extra query parameters.
  @return the URI built from the inputs.