`
Supanccy2013
  • 浏览: 213378 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

21312

    博客分类:
  • java
fp 
阅读更多
http://supanccy2013.iteye.com/admin/blogs/new

package main;
import java.io.File;
public class Main
{
public static void main(String[] args) throws Exception
{
// 递归显示C盘下所有文件夹及其中文件
File root = new File("d:/temp");
showDir(root);
}

public static void showDir(File dir) {
File[] fstr = dir.listFiles();

if(fstr == null || (fstr != null && fstr.length==0)){    //判断一下是否为空
return;
}
for(File file : fstr) {
if(file.isDirectory())
showDir(file);
else if(file.isFile() && file.getName().endsWith(".txt"))
System.out.println(file);
}
}
}



http://zhidao.baidu.com/link?url=AqtyzFp2Ja6Z14-FV58ar4pbRMk9NUCn7KyUp_wG7uFZ6dpkXKOFU3bEYup9fp4Zov8dHictEoY6FQ8WPiMZmq




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics