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 ) ; }
cast a string to a url