import java.io.File; import java.io.IOException; public class main { public static void main(String[] args) throws IOException { File file = new File("E:\\clhcmdb"); listDir(file, 0); } static void listDir(File dir, int level) { File[] files = dir.listFiles(); if (files != null) { for (File file : files) { for (int i = 0; i < level; i++) { System.out.print(" "); } if (file.isDirectory()) { System.out.println(file.getName()); listDir(file, level + 1); } else { System.out.println(file.getName()); } } } } }
Sign in to make a reply
大黑与small白