文件过滤器

    public static void main(String[] args) throws IOException {
    
        method_6();
    }
    public static void method_6() {
        File file=new File("c:\\");
        String[] names=file.list(new FilenameFliter_by());//得到文件目录

        for(String name:names)
        {
            sop(name);
        }        
    }
import java.io.File;
import java.io.FilenameFilter;

public class FilenameFliter_by implements FilenameFilter {

    @Override
    public boolean accept(File dir, String name) {
        
        return name.endsWith(".java");
    }

}

posted on 2012-10-19 17:06  蝌蚪的精神  阅读(128)  评论(0编辑  收藏  举报

导航