What is a malformed url, and why is it exceptional?
When you create an instance of the java.net.URL class, its constructor can throw a MalformedURLException. This occurs when the URL is invalid. When it is thrown, it isn’t because the host machine is down, or the URL path points to a missing file; a malformed URL exception is thrown when the URL cannot be correctly parsed. Common mistakes include :- • leaving out a protocol (eg “www.microsoft.com” instead of “http://www.microsoft.com/”) • specifying an invalid protocol (eg “www://netscape.com”) • leaving out the ‘:’ character (eg http//www.micrsoft.com/) MalformedURLException will not be thrown if :- • the host name is invalid (eg “www.microsoft-rules-the-world.com”) • the path is invalid (eg “http://www.microsoft.com/company_secrets.