In examples 20.1 through 20.5 you also need to import java.io.IOException. Add the following line to the top of each of those examples.
import java.io.IOException;
On page 485, the quote marks in the code fragment at the bottom of the page should be straight, not curly.
In program 20.6 on pages 493-495, the try-catch block is unnecessary and may be removed. The corrected program is
import java.io.File;
import java.io.IOException;
public class FileInfo {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
File f = new File(args[i]);
if (f.exists()) {
System.out.println("getName: " + f.getName());
System.out.println("getPath: " + f.getPath());
System.out.println("getAbsolutePath: " +
f.getAbsolutePath());
System.out.println("getParent: " + f.getParent());
if (f.canWrite()) System.out.println(f.getName() +
" is writable.");
if (f.canRead()) System.out.println(f.getName() +
" is readable.");
if (f.isFile()) {
System.out.println(f.getName() + " is a file.");
}
else if (f.isDirectory()) {
System.out.println(f.getName() + " is a directory.");
}
else {
System.out.println("What is this?");
}
if (f.isAbsolute()) {
System.out.println(f.getName() +
" is an absolute path.");
}
else {
System.out.println(f.getName() +
" is not an absolute path.");
}
System.out.println("Last Modified" +
f.lastModified());
System.out.println(f.getName() + " is " +
f.length() + " bytes.");
System.out.println(f.getName() + " is " +
f.length() + " bytes.");
}
else {
System.out.println("I'm sorry. I can't find the file "
+ args[i]);
}
}
}
}