zoukankan      html  css  js  c++  java
  • 递归算法java

    package test;
    
    import java.io.File;
    import java.io.IOException;
    
    public class FileTest {
        public static void main(String[] args) {
            String path="d:\aaa";
            File f=new File(path);
            showFile(f);
            
        }
        
        //递归算法
        //返回当前目录下的所有文件 对象形式
        public static void showFile(File f){
            
            File arr[]=f.listFiles();
            if(arr.length==0){
                System.out.println(f.getAbsolutePath());  //获取f绝对路径
    
            }else{
                for(File ftemp:arr){
                    if(ftemp.isDirectory()){    //如果还是一个文件夹,那么调用自己来继续执行判断File是否是目录,是目录返回true
                        showFile(ftemp);
                    }else{
                        System.out.println(ftemp.getAbsolutePath());
                    }
                    
                }
            }
            
        }
    
    }

    }

  • 相关阅读:
    Adobe Flash Player 设置鼠标点不到允许或者拒绝!
    bzoj2096
    bzoj2789
    LA3353
    poj2594
    bzoj2427
    bzoj1076
    bzoj2818
    bzoj3668
    bzoj2006
  • 原文地址:https://www.cnblogs.com/tytr/p/5897079.html
Copyright © 2011-2022 走看看