一:上码
package cn.wyj.one;import java.io.File;public class Demo8_递归打印目录树 {public static void main(String[] args) {File f = new File("C:/亚洲");printfile(f,0);}static void printfile(File f,int level){for( int i = 0; i < level; i++){System.out.print("-");}System.out.println(f.getName());if(f.isDirectory()){//如果不是目录结构就终止递归File files[] = f.listFiles();for(File temp: files){printfile(temp,level+1);}}}}