Java URL Create concatenateURL(URL url, String query)

Here you can find the source of concatenateURL(URL url, String query)

Description

concatenate URL

License

Open Source License

Declaration

public static URL concatenateURL(URL url, String query) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.MalformedURLException;
import java.net.URL;

public class Main {
    public static URL concatenateURL(URL url, String query) {
        try {//ww  w .jav a  2  s.com
            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);
        }
    }
}

Related

  1. buildUrlPath(String baseUrl, String childUrl)
  2. buildUrlsList(final String domain, final String... paths)
  3. buildURLString(Iterable elements, String joiner)
  4. concatenate(URL server, String address)
  5. concatenateURL(final URL url, final String query)
  6. concatUrl(final URL baseUrl, final String extraPath)
  7. concaturl(final URL p_base, final String p_string)
  8. constructURL(URL base, String url, boolean stripRef)
  9. constructURLQueryString(Map urlParameters)