Corrections to Chapter 5 of Java Network Programming, Retrieving Data with URLs

p. 99: 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.


[ Java Network Programming Corrections | Java Network Programming Home Page | Table of Contents | Examples | Order from Amazon ] ]

Copyright 1998, 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified December 4, 1999