List of utility methods to do URL Create
URL | concaturl(final URL p_base, final String p_string) concats an URL with a path return new URL(p_base.toString() + p_string).toURI().normalize().toURL(); |
URL | constructURL(URL base, String url, boolean stripRef) Construct a URL from its basic parts. URL result = new URL(base, url); String file = result.getFile(); String protocol = result.getProtocol(); String host = result.getHost(); int port = result.getPort(); String ref = result.getRef(); StringBuilder sb = new StringBuilder(file); int index = sb.indexOf(" "); ... |
String | constructURLQueryString(Map This method is the opposite for extractURLParameters(String url) .
if (urlParameters != null) { StringBuilder queryString = new StringBuilder(); for (Map.Entry<String, String> parameter : urlParameters.entrySet()) { if (queryString.length() > 0) queryString.append("&"); queryString.append(urlEncodeQuery(parameter.getKey()) + "=" + urlEncodeQuery(parameter.getValue())); return (queryString.toString()); ... |
String | constructURLString(Map Expand the map of parameters to construct a URL string StringBuffer url = new StringBuffer(); boolean first = true; for (Map.Entry<String, String> entry : parameters.entrySet()) { try { if ((entry.getValue() == null) || (entry.getKey() == null)) { continue; if (entry.getValue().length() == 0) { ... |
URL | convertToURL(String host) Convert a path to a url. try { return new URL(host); } catch (Throwable e) { final String error = "Unable to convert a supplied host spec to a url: " + host; throw new IllegalArgumentException(error); |
URL | convertToURL(String url) convert To URL if (url != null) { return new URL(url); } else { throw new MalformedURLException("URL is not valid"); |
URL[] | convertToUrl(String[] paths) Convert string paths into URL class paths. ArrayList<URL> list = new ArrayList<URL>(); for (int i = 0; i < paths.length; i++) { URL url = convertToUrl(paths[i]); if (url != null) { list.add(url); return list.toArray(new URL[list.size()]); ... |
URL[] | convertToURLs(String[] hosts) Convert a set of host path statements to formal urls. ArrayList list = new ArrayList(); for (int i = 0; i < hosts.length; i++) { URL url = convertToURL(hosts[i]); if (url != null) list.add(url); return (URL[]) list.toArray(new URL[0]); |
URL | createURL(final String address) create URL try { return new URL(address); } catch (final MalformedURLException e) { throw new RuntimeException("Can't create URL object for: " + address, e); |
String | createURL(final String protocol, final String userInfo, final String host, final int port, final String path, final String query, final String ref) create URL final StringBuilder sb = new StringBuilder(); sb.append(protocol); sb.append("://"); if (userInfo != null) { sb.append(userInfo); sb.append("@"); sb.append(host); ... |