public static void showDir(File dir,int level)
{
System.out.println(getLevel(level)+dir.getName());
level++;
File[] files = dir.listFiles();
for(int x=0; x<files.length; x++)
{
if(files[x].isDirectory())
showDir(files[x],level);
else
System.out.println(getLevel(level)+files[x]);
}
}
Exception in thread "main" java.lang.NullPointerException
at cn.itheima.test4.TraversalList.showDir(TraversalList.java:37)
at cn.itheima.test4.TraversalList.showDir(TraversalList.java:41)
at cn.itheima.test4.TraversalList.showDir(TraversalList.java:41)
at cn.itheima.test4.TraversalList.getDirList(TraversalList.java:15)
at cn.itheima.test4.TraversalListTest.main(TraversalListTest.java:15)
|
|