首页 > 编程语言 > 详细

递归算法算出某个目录下所有目录和文件

时间:2019-05-12 20:21:49      阅读:135      评论:0      收藏:0      [点我收藏+]
public class $ { 
    public static void main(String[] args) { 
        String path = "D:\\111"; 
        test(path); 
    }    
private static void test(String path) { File f = new File(path); File[] fs = f.listFiles(); if (fs == null) { return; } for (File file : fs) { if (file.isFile()) { System.out.println(file.getPath()); } else { test(file.getPath()); } } } }

 

递归算法算出某个目录下所有目录和文件

原文:https://www.cnblogs.com/zhangxiong-tianxiadiyi/p/10853382.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!