Java Utililty Methods URL Create

List of utility methods to do URL Create

Description

The list of methods to do URL Create are organized into topic(s).

Method

StringbuildUrl(final String baseUrl, final Map params, final String... parts)
build Url
if (parts == null || parts.length < 1) {
    return baseUrl;
final StringBuilder urlBuilder = new StringBuilder();
if (!parts[0].startsWith(baseUrl)) {
    urlBuilder.append(baseUrl);
for (String part : parts) {
...
StringbuildUrl(final String baseUrl, final String basePath, final String[] parts)
build Url
return buildUrl(baseUrl, basePath, null, parts);
StringbuildUrl(final String baseUrl, final String... parts)
Given a base URL and some path fragments, build a complete, valid URL
if (parts == null || parts.length < 1) {
    return baseUrl;
final StringBuilder urlBuilder = new StringBuilder();
if (parts[0] == null || !parts[0].startsWith(baseUrl)) {
    urlBuilder.append(baseUrl);
for (String part : parts) {
...
URLbuildUrl(final String domain, final String path)
Builds an URL given a domain and a path.
try {
    return new URL(new URL(domain), path);
} catch (MalformedURLException e) {
    throw new RuntimeException(e);
URLbuildUrl(String base, Map params)
build Url
StringBuffer sb = new StringBuffer(base);
sb.append("?");
Iterator ip = params.keySet().iterator();
while (ip.hasNext()) {
    String param = (String) ip.next();
    if (param == null)
        continue;
    sb.append(param);
...
StringbuildUrl(String baseUrl, Map queryParams, String anchor)
Builds an URL.
StringBuffer url = new StringBuffer();
url.append(baseUrl);
if (queryParams != null && !queryParams.isEmpty()) {
    url.append(QUERY_CHAR);
    url.append(makeUriString(queryParams));
if (anchor != null) {
    url.append(ANCHOR_CHAR);
...
URLbuildUrl(String context, String... relocations)
Use URL context and one or more relocations to build end URL.
try {
    return buildUrl(new URL(context), relocations);
} catch (MalformedURLException e) {
    throw new AssertionError("URL('" + context + "') isn't valid URL");
StringbuildUrl(String context, String... relocations)
Use URL context and one or more relocations to build end URL.
URL url = new URL(context);
for (String move : relocations) {
    url = new URL(url, move);
return url.toString();
URLbuildUrl(String host, int port, String path, Map parameters)
Build a request URL.
return buildUrl("http", port, path, parameters);
URLbuildUrl(String host, int port, String path, Map parameters)
Build a request URL.
StringBuffer buffer = new StringBuffer();
if (!host.startsWith("http://")) {
    buffer.append("http://");
buffer.append(host);
if (port > 0) {
    buffer.append(':');
    buffer.append(port);
...