import java.io.File;
public class TestFile {
public static void main(String[] args) {
File file = new File("D:/A");
tree(file,0);
}
private static void tree(File f,int level) {
String tabSpace = "";
for(int i=0; i<level;i++) {
tabSpace+=" ";
}
File[] childs = f.listFiles();
for(int i=0; i<childs.length; i++) {
System.out.println(tabSpace + childs[i].getName());
if(childs[i].isDirectory()) {
tree(childs[i],level+1);
}
}
}
}