package com.curtis;
import java.io.File;
public class TestFile {
public static void main(String[] args) {
String path = "C:" + File.separator + "curtis" ;
printFile(new File(path));
}
public static void printFile(File file) {
if (file.isFile()) {
System.out.println("您给定的是一个文件");
} else {
File[] fileLists = file.listFiles();
for (int i = 0; i < fileLists.length; i++) {
System.out.println(fileLists[i].getName());
if (fileLists[i].isDirectory()) {
printFile(fileLists[i]);// 递归
}
}
}
}
}