高手请看,这个编译的时候没有问题,但是在运行的时候就报错,提示空指针异常
import java.io.*;
public class TestEx501 {
public static void main(String args[]) {
File dir = new File("d://ex");
Filter filter = new Filter("java");
System.out.println("list java files in directory " + dir);
String files[] = dir.list(filter);
for (int i = 0; i < files.length; i++) {
File f = new File(dir, files[i]);
if (f.isFile())
System.out.println("file " + f);
else
System.out.println("sub directory " + f);
}
}
}
|