Java File Find find(File dir, String suffix, Set ignore)

Here you can find the source of find(File dir, String suffix, Set ignore)

Description

find

License

Open Source License

Declaration

public static List<File> find(File dir, String suffix, Set<String> ignore) 

Method Source Code

//package com.java2s;
/**// w w w .  j a va 2s  .  c  o  m
 * Copyright 2012-2015 Rafal Lewczuk <rafal.lewczuk@jitlogic.com>
 * <p/>
 * This is free software. You can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * <p/>
 * This software is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * <p/>
 * You should have received a copy of the GNU General Public License
 * along with this software. If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.File;

import java.util.ArrayList;
import java.util.List;

import java.util.Set;

public class Main {
    public static List<File> find(File dir, String suffix, Set<String> ignore) {
        List<File> lst = new ArrayList<File>();

        for (String fn : dir.list()) {
            if (ignore.contains(fn)) {
                continue;
            }

            File f = new File(dir, fn);

            if (f.isFile() && fn.endsWith(suffix)) {
                lst.add(f);
            }

            if (f.isDirectory() && !f.getPath().startsWith(".")) {
                lst.addAll(find(f, suffix, ignore));
            }
        }

        return lst;
    }
}

Related

  1. find(File absolutePath, FileFilter filter)
  2. find(File baseFile, String regex)
  3. find(File dir, String baseName)
  4. find(File file)
  5. find(File file, Pattern pattern, int limit, List found, Set visited)
  6. find(File folder, final String name)
  7. find(File path, Boolean recursive)