When you create an instance of the java.net.URL class, its constructor can throw a MalformedURLException.
This occurs when the URL is invalid.
A malformed URL exception is thrown when the URL cannot be correctly parsed.
It is not thrown, when :
- The host machine is down
- URL path points to a missing file
Common mistakes include :
- leaving out a protocol (eg "www.microsoft.com" instead of "http//www.microsoft.com/")
- specifying an invalid protocol (eg "http: // www: //netscape.com")
- leaving out the ':' character (eg http// www.micrsoft.com/)
MalformedURLException will not be thrown if :
- host name is invalid (eg "http: //www.microsoft-rules-the-world.com")
- path is invalid (eg "http: //www.microsoft.com/company_secrets.htm")
No comments:
Post a Comment
Note: only a member of this blog may post a comment.