Java Cookbook By Ian F. Darwin This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. (Please specify the printing date of your copy.) This page was last modified on March 16, 2004. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Npage-numberN: new feature or API since the book was published CONFIRMED errors: Chapter 4, Regular Expressions. N93N The examples in this chapter use the org.apache.regexp package, one of several available APIs at the time the book was written. Java 2 SDK 1.4 and later includes a new package, java.util.regex, which provides the same functionality but with a slightly different API. I have some notes on conversion from org.apache.regexp package to java.util.regex for those who wish to use the "official" API in new development. These can be found at http://javacook.darwinsys.com/regex.html Chapter 5, Numbers [105] javacook/RE/BookRank.java line 21; There's a compiler error when trying to compile javacook/RE/BookRank.java: unclosed string literal: public final static String QUERY = " "http://www.quickbookshops.web/cgi-bin/search?isbn="; The quote on line 21 should be removed: public final static String QUERY = "http://www.quickbookshops.web/cgi-bin/search?isbn="; ?121? The floating point comparison (equals method) shown here works fine for most ranges of numbers, but requires you to specify the "epsilon" value. A reader has pointed out that you can write this code such that it scales the epsilon, at the cost of a few additional calls on the math library, by promoting EPSILON to a field in the class, and writing public static boolean equals(double a, double b) { return Math.abs(a - b) < EPSILON * Math.max(Math.abs(a), Math.abs(b)); } {213} The clone() method does not need a throws clause for CloneNotSupportedException. {268} UnZip.java The UnZip program has problems with some Zip files that don't have proper directory entries, particularly on MS-Windows. A revision that is more careful to pre-create the directories is available from the author's web site - http://javacook.darwinsys.com/ Chapter 11, Serial IO. Chapter 21, XML ?659? The doNode() method is not shown; it must process whatever nodes you are interested in, and call doRecursive() with others, to walk the entire tree. Changing the call on doNode() to doRecursive() will print all the nodes. {674} In the code for the TickerServer interface, the code contains: //...code public interface TickerServer extends java.rmi.Remote { public static final String LOOKUP_NAME = "Ticker Service"; //...more code On some implementations, a MalformedURLException is thrown because of the space. Changing the constant String to "TickerService" will resolve the problem. Chapter 24, Threads <725> If you read 24.5 but not 24.6, you might get confused (as a reviewer on Amazon.com apparently did) and think that synchronization locks a method (or that I think this is the case). In fact, the lock is an attribute of an object; a synchronized method running in an object does lock out all other synchronized methods running in the same object (or synchronized blocks synchronized on the object). This will be clarified in the next edition. Chapter 26, Using Java with Other Languages {796} Not shown in the book, but online in javacooksrc/DBM/jdbm.c. A call to malloc() incorrectly uses k.dsize instead of v.dsize to allocate the size, causing the example to not work. line 97: is: v.dptr = malloc(k.dsize); // XXX should be: v.dptr = malloc(v.dsize); // XXX