日期:2014-05-20 浏览次数:20732 次
import java.io.File;
import java.io.IOException;
public class Searchfilm {
public static void main(String[] args) throws IOException {
String path = "E:/";
serch(path);
}
public static void serch(String path) throws IOException {
File listFile[];
int FileCount = 0, i;
File file = new File(path);
if (!file.exists()) {
System.out.println(path + "不存在!");
return;
}
if (file.isDirectory()) {
listFile = file.listFiles();
for (i = 0; i < listFile.length; i++) {
if (listFile[i].isFile()) {
if (listFile[i].getCanonicalPath().endsWith(".txt"))
System.out.println(listFile[i].getCanonicalPath());
FileCount++;
} else {
serch(listFile[i].getCanonicalPath() + "/");
// System.out.println(listFile[i].getCanonicalPath());
}
}
}
}
}
for (i = 0; listFile!=null && (i < listFile.length); i++) {