- public class FileDemo3 {
- public static void main(String[] args) {
- File dir = new File("c:/");
- showDir(dir);
- }
- public static void showDir(File dir)
- {
- System.out.println(dir);
- File[] flies = dir.listFiles();
- for(int x=0;x<flies.length;x++)
- {
- if(flies[x].isDirectory())
- showDir(flies[x]);
- else
- System.out.println(flies[x]);
-
- }
-
- }
复制代码 这节课上面,直接出了空指针Exception in thread "main" java.lang.NullPointerException,在逻辑上应该是没有问题的呀,我只是换了源而已,大神指点一下
|