java递归遍历资料
java递归遍历文件
this recursive function
public class Test { public static void main(String[] args) throws IOException { File file = new File("E:\\plan"); Test.recursive(file); } public static void recursive(File file) throws IOException { // do not try to index files that cannot be read if (file.canRead()) { if (file.isDirectory()) { String[] files = file.list(); // an IO error could occur if (files != null) { for (int i = 0; i < files.length; i++) { recursive(new File(file, files[i])); } } } else { System.out.println("adding " + file); } } } }