import java.io.*;
public class A {
   static long count=0;
    public static void index(File f) throws Exception {
if (f.isDirectory()&&f.canRead()) {
File[] filearr = f.listFiles();
System.out.println(filearr+"***"+f.getCanonicalPath());
for (int i = 0; i < filearr.length; i++) {//这里弹出NullPointerException
if (filearr[i].isFile()) {
String path=filearr[i].getCanonicalPath();
System.out.println(path);
count++;
} else
index(filearr[i]);
}
}
}
    public static void main(String[] args) throws Exception{
      index(new java.io.File("C:\\System Volume Information"));     
    }
}首先‘C:\\System Volume Information'这个文件夹双击是无权访问的
编译源文件后,在命令里运行,就会出现注释处的异常,因为filearr 为null
但是把这个程序放入jcreator里运行,一切正常,也能访问这个文件夹了
不知道这有没有谁遇到这种情况????