posts - 6,  comments - 4,  trackbacks - 0
再递归 , 递归递归, 不断递归。。。。。


import java.io.*;

public class TestList
{
    
public static void main(String[] args)
    
{
        File f 
= new File("G:/JAVA");
        tree(f,
0);
    }


    
public static void tree(File f, int level)
    
{
        String pre 
= "";
        
for(int i = 0; i<level ; i++)
        
{
            pre 
+= "    ";
        }


        File[] childs 
= f.listFiles();
        
for(int i = 0; i<childs.length; i++)
        
{
            System.out.println(pre 
+ childs[i].getName());
            
if(childs[i].isDirectory())
            
{
                tree(childs[i], level 
+ 1);
            }

        }

    }

}
posted on 2009-04-08 14:37 shivaree 阅读(116) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: