code: public static URL toURL(String strUrl, int port, boolean encodeIfNecessary) throws MalformedURLException {
  	URL url;
  	try {
  	    url = new URL(strUrl);
  	}
  	catch (MalformedURLException mue) {
  	    url = new URL("http://" + strUrl);
  	}
  	if (!encodeIfNecessary) return url;
  	return encodeURL(url, port);
      }
docs: cast a string to a url
  
  @param strUrl string represent a url
  @return url from string
  @throws MalformedURLException