public static void printDir(File dir, int depth){ System.out.println(dir.getName() + "/"); int count = 0; for (File f: dir.listFiles()){ for (int i = 1; i < depth+1; i++){ System.out.print(" "); } if (f.isFile()){ count ++; System.out.println(count + "." + f.getName()); } else{ int newdepth = depth + 1; printDir(f, newdepth); } } }}
Sign in to make a reply
糊涂蛋李恩记