Here you can find the source of createURL(final String address)
public static URL createURL(final String address)
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL createURL(final String address) { try {//from w ww .j a v a 2 s . c o m return new URL(address); } catch (final MalformedURLException e) { throw new RuntimeException("Can't create URL object for: " + address, e); } } public static URL createURL(final URL url, final String query) { try { if ((url.getQuery() != null) && (!url.getQuery().isEmpty())) { return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "&" + query); } return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "?" + query); } catch (final MalformedURLException ex) { throw new RuntimeException( "Can't create URL object for query: " + query + ", URL: " + url, ex); } } }