code: public static String getURL(URI uri) {
          final StringBuilder buffer = new StringBuilder();
          buffer.append(uri.getPath());
          
          String query = uri.getQuery();
          String fragment = uri.getFragment();
  
          if (StringUtils.isNotBlank(query)) {
              buffer.append('?').append(query);
          }
  
          if (StringUtils.isNotBlank(fragment)) {
              buffer.append('#').append(fragment);
          }
  
          return buffer.toString();
      }
docs: Creates and URL with only path and if present query and
  fragment, e.g. /path/data?key=value#fragid1
  
  @param uri The URI to generate from
  @return The generated URL