Java File Find find2(File baseDir, FileFilter filter, List files, boolean includeHiddenFiles)

Here you can find the source of find2(File baseDir, FileFilter filter, List files, boolean includeHiddenFiles)

Description

find

License

Open Source License

Declaration

private static void find2(File baseDir, FileFilter filter, List<File> files, boolean includeHiddenFiles) 

Method Source Code

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

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

import java.util.List;

public class Main {
    private static void find2(File baseDir, FileFilter filter, List<File> files, boolean includeHiddenFiles) {
        assert baseDir != null && filter != null && files != null;
        for (File f : baseDir.listFiles()) {
            if (f.equals(baseDir)) {
                continue;
            }/*from w w  w.j av  a  2 s . c om*/
            // Hidden?
            if (!includeHiddenFiles && f.isHidden()) {
                continue;
            }
            assert includeHiddenFiles || !f.getName().startsWith(".") : f;
            // Add?
            if (filter.accept(f)) {
                if (f.exists()) {
                    files.add(f);
                } else {
                    // a broken symlink -- skip it
                }
            }
            // Recurse
            if (f.isDirectory()) {
                find2(f, filter, files, includeHiddenFiles);
            }
        }
    }
}

Related

  1. find(String _sSourceString, String _sReg, int group)
  2. find(String executable, File... dirs)
  3. find(String name, File dir)
  4. find(String path, String matcher)
  5. find(String path, String suffix)
  6. findByExt(File base, String ext)
  7. findByExtension(final File directory, final String extension)
  8. findByFileName(List files, String fileName)
  9. findExe(String exeName, String... path)