File dir = new File ("c:\\test") ;
假设说test文件夹下有一个 movie 文件夹 ,当用如下方法是是行不通的:
String[] fileNamesString = dir.list();
然后遍历的时候这么判断:
import java.io.*;
public class Test{
public static void main(String[] args){
File dir = new File ("c:\\test") ;
String[] fileNamesString = dir.list();
for ( int i = 0 ; i < fileNamesString.length ; i++)
{
File temp = new File(fileNamesString[i]);
boolean b = temp.isDirectory() ;
System.out.println(b);
}
}
}
为什么打印的都是false ,求解? |