args[0]
should be args[i]
in Example 5-12.
That is the main()
method should look like this:
public static void main (String args[]) {
// Loop through the command line arguments
for (int i = 0; i < args.length; i++) {
//Open the URL for reading
try {
URL root = new URL(args[i]);
PageSaver ps = new PageSaver(root);
ps.saveThePage();
}
catch (MalformedURLException e) {
System.err.println(args[i] + " is not a parseable URL");
System.err.println(e);
}
} // end for
} // end main
pp. 103-104: In Example 5-13 the line
querystring.trim();
should be
querystring = querystring.trim();
Strings are constant. The trim()
method returns a new string.
It does not change the current string.