IO流遍历文件夹下所有文件问题

import java.io.File;

/**
 * @author 王恒
 * @datetime 2017年4月20日 下午2:24:32
 * @description  递归调用
 *
 */
public class TestFile {

	public static void main(String[] args) {
		File f = new File("E:"+File.separator+"影视");
		fun(f);
	}

	public static void fun(File file){
		if(file.isDirectory()){
			for(File f:file.listFiles()){
				fun(f);
			}
		}else{
			System.out.println(file.getAbsolutePath());
		}
	}
}


     运行效果:
                   E:影视java-web-j2e学习建议路线.doc
                   E:影视javaweb学习路线.txt
                   E:影视servlet01.png
                   E:影视何泓姗-匆匆那年6a1c9504fc2d562ecaeef5ae41190ef77c66c78.jpg
                   E:影视何泓姗-匆匆那年8dc11a98226cffcfa7a8305ba014a90f703ea4b.jpg
 



    

  

原文地址:https://www.cnblogs.com/1020182600HENG/p/6738219.html