Java Recursive List recursiveListFiles(File baseDir, final FileFilter filter)

Here you can find the source of recursiveListFiles(File baseDir, final FileFilter filter)

Description

recursive List Files

License

Open Source License

Declaration

public static List<File> recursiveListFiles(File baseDir, final FileFilter filter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileFilter;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<File> recursiveListFiles(File baseDir, final FileFilter filter) {
        FileFilter dirFilter = new FileFilter() {
            public boolean accept(File pathname) {
                return pathname.isDirectory() || filter.accept(pathname);
            }//from  w w  w  .  j  ava 2s  .c om
        };
        File[] fileArray = baseDir.listFiles(dirFilter);
        List<File> files = new ArrayList<File>(fileArray.length);
        for (int i = 0; i < fileArray.length; i++) {
            if (fileArray[i].isDirectory()) {
                files.addAll(recursiveListFiles(fileArray[i], filter));
            } else {
                files.add(fileArray[i]);
            }
        }
        return files;
    }
}

Related

  1. recursiveList(File dir, FilenameFilter filter)
  2. recursiveListFile(File folder)
  3. recursiveListFiles(File dir, FileFilter filter)
  4. recursiveListFiles(File file, List files)
  5. recursiveListFiles(String path)
  6. recursiveListFilesHelper(File dir, FileFilter filter, List fileList)