/**
* 递归读取文件夹下的 所有文件
*
* @param testFileDir 文件名或目录名
*/
private static void loopOutAllFileName(String testFileDir) {
//因为new File(null)会空指针异常,所以要判断下
if (testFileDir == null) {
return;
}

File[] testFile = new File(testFileDir).listFiles();
if (testFile == null) {
return;
}
for (File file : testFile) {
if (file.isFile()) {
System.out.println(file.getName());
} else if (file.isDirectory()) {
System.out.println("------- this is a directory, and its files are as follows -------");
loopOutAllFileName(file.getPath());
} else {
System.out.println("文件读入有误!");
}
}
}