一路拾遗
Collect By Finding All The Way ......
posts - 81,comments - 41,trackbacks - 0

import java.io.*;
import java.util.*;

public class ParseFileList {
        
    
private List fileList = new ArrayList();

    
public synchronized void bianli(String dir_path)
    
throws FileNotFoundException
    {
        File dir 
= new File(dir_path);
        
if (!dir.exists())
        {
            
throw new FileNotFoundException();
        }
        
if (!dir.isDirectory()) 
        {
            
//System.out.println(dir.toString()+"is File.");
            fileList.add(dir);
        } 
        
else
        {
            File[] fe 
= dir.listFiles();
            
for (int i = 0; i < fe.length; i++
            {
                
if (fe[i].isDirectory()) 
                {
                    
//System.out.println(fe[i].toString()+"is Dir");
                    bianli(fe[i].toString());
                }
                
else
                {
                    
//System.out.println(fe[i].toString());
                    fileList.add(fe[i]);
                }
            }
        }
    }
    
public List getFileList() {
        
return fileList;
    }
}

posted on 2008-07-23 16:53 胖胖泡泡 阅读(88) 评论(0)  编辑  收藏

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


网站导航: