List of utility methods to do URL Create
String | buildUrl(String URL, Map build Url if (URL == null) return null; String qs = buildQueryString(params); return URL.indexOf("?") < 0 ? URL + "?" + qs : URL + "&" + qs; |
URL | buildUrl(String urlPrefix, String urlSuffix) build Url String urlPrefixFixed = urlPrefix.trim(); while (urlPrefixFixed.endsWith("/")) { urlPrefixFixed = urlPrefixFixed.substring(0, urlPrefixFixed.length() - 1); URL url = new URL(urlPrefixFixed + "/" + urlSuffix); return url; |
String | buildURL(URI base, Multimap build URL if (params.isEmpty()) { return base.toString(); } else { return base + "?" + buildQueryString(params); |
String | buildUrlPath(String baseUrl, String childUrl) build Url Path try { URI oldUri = new URI(baseUrl); URI resolved = oldUri.resolve(childUrl); return resolved.toString(); } catch (URISyntaxException e) { e.printStackTrace(); return baseUrl; |
List | buildUrlsList(final String domain, final String... paths) Builds a List of URL s given a domain and 1..N paths relative to the domain. return Arrays.stream(paths).map(p -> buildUrl(domain, p)).collect(Collectors.toList());
|
String | buildURLString(Iterable build URL String Iterator<String> iter = elements.iterator(); if (!iter.hasNext()) { return ""; String wholequery = iter.next(); try { while (iter.hasNext()) { wholequery += joiner + URLEncoder.encode(iter.next(), "UTF-8"); ... |
URI | concatenate(URL server, String address) Builds a complete URI given a URL that specifies the server and a string that is the remainder of the query. try { return new URL(server, Preconditions.checkNotNull(address)).toURI(); } catch (MalformedURLException | URISyntaxException e) { throw new IllegalArgumentException(e); |
URL | concatenateURL(final URL url, final String query) Concatenates the given java.net.URL and query. try { if (url.getQuery() != null && url.getQuery().length() > 0) { return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "&" + query); } else { return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "?" + query); } catch (final MalformedURLException ex) { throw new IllegalArgumentException("Could not concatenate given URL with GET arguments!", ex); ... |
URL | concatenateURL(URL url, String query) concatenate URL try { return url.getQuery() != null && url.getQuery().length() > 0 ? new URL(url.getProtocol(), url.getHost(), url.getFile() + "&" + query) : new URL(url.getProtocol(), url.getHost(), url.getFile() + "?" + query); } catch (MalformedURLException e) { throw new IllegalArgumentException("Concatenated URL was malformed: " + url.toString() + ", " + query); |
URL | concatUrl(final URL baseUrl, final String extraPath) concat Url try { URI uri = baseUrl.toURI(); String newPath = uri.getPath() + (uri.getPath().endsWith("/") ? "" : "/") + extraPath; URI newUri = uri.resolve(newPath); return newUri.toURL(); } catch (Exception e) { throw new RuntimeException("Can't add extra path " + extraPath + " to url " + baseUrl, e); |