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:\影视\何泓姗-匆匆那年\06a1c9504fc2d562ecaeef5ae41190ef77c66c78.jpg
                   E:\影视\何泓姗-匆匆那年\08dc11a98226cffcfa7a8305ba014a90f703ea4b.jpg
 



    

  

posted @ 2017-04-20 13:04  奋斗的少年WH  阅读(377)  评论(0编辑  收藏  举报