标签:
package chengbaoDemo;
import java.io.File;
import java.io.IOException;
public class TestIOFile {
public static void main(String[] args) {
File f = new File("D:/Project/java/Test");
printTreeFile(f, 0);
}
public static void printTreeFile(File file, int level) {
for (int i = 0; i < level; i++) {
System.out.print("\t");
}
String fileName = file.getName();
System.out.println(fileName);
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File f: files) {
printTreeFile(f, level + 1);
}
}
}
}
标签:
原文地址:http://www.cnblogs.com/chengbao/p/5185670.html