A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

/*
        显示指定目录下所有java文件的绝对路径。
*/
public class Test4
{
        public static void main(String[]args)
        {
                File file = new File("e:\\");
                show(file);
       
        }
        public static void show(File file)
        {
                File[]  files = file.listFiles();
                for(File f:files)
                {
                        if(f.isFile())
                        {                               
                                        System.out.println(f.getAbsolutePath());                       
                        }
                        else
                        {
                                show(f);
                        }
                }
        }
}


评分

参与人数 1技术分 +1 收起 理由
曹秀云 + 1 神马都是浮云

查看全部评分

1 个回复

倒序浏览
同问?遍历有的目录不会出现异常!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马