import java.io.*;
class Test
{
public static void main(String[] args)throws IOException
{
File file = new File("F:\\");
file2List(file);
}
public static void file2List(File file){
System.out.println(file.exists());
File[] files = file.listFiles();
for(int x=0; x<files.length; x++){
if(files[x].isDirectory())
file2List(files[x]);
else
System.out.println(files[x]);
}
}
}
提示报错:Exception in thread "main" java.lang.NullPointerException
at Test.file2List(Test.java:13)
at Test.file2List(Test.java:15)
at Test.file2List(Test.java:15)
at Test.main(Test.java:7)
搞不懂啊!!!!
|