Modify your solution to Homework #4 (the bookmarks program)
and add
code to validate the URL portion of each bookmark -- that is,
ensure that it corresponds to a real Web document. Validate
URLs at two points:
- While reading in bookmarks from the specified file.
If the bookmarks file contains an invalid URL,
produce an error message and don't add the
entry to collection of bookmarks to be managed by
the program. Since there could be multiple error
messages, write them to standard output.
- When adding a bookmark using the "add" button.
If the URL typed in by the user is invalid, produce
an error message and don't add the entry. Here,
display the error message as text at the top of the
user-interface window (easiest is probably to use
a Label, setting its value to "Invalid URL" when
an attempt is made to add a bookmark with an invalid
URL, and then setting it back to blanks on the next
operation).
You should reject URLs that (1) are invalid in form (e.g.,
junk://www.junk.xxxx), or (2) don't correspond to
a real Web document.
If you don't have a good solution to Homework #4, you
may start from the sample solution.