October 2011
Beginner
432 pages
10h 18m
English
When you set up a URL object, you must make sure the text used to set up the address is in a valid format. http://workbench.cadenhead.org and http://www.samspublishing.com are valid, but http:www.javaworld.com would not be because of missing “/” marks.
The getURL(String) method takes a web address as an argument, returning a URL object representing that address. If the string is not a valid address, the method returns null instead:
URL getURL(String urlText) { URL pageURL = null; try { pageURL = new URL(getDocumentBase(), urlText); } catch (MalformedURLException m) { // do nothing } return pageURL;}
The try-catch block deals with any MalformedURLException errors that occur when ...
Read now
Unlock full access