Java File Find find(String path, String matcher)

Here you can find the source of find(String path, String matcher)

Description

find

License

Open Source License

Declaration

public static List<File> find(String path, String matcher) 

Method Source Code


//package com.java2s;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<File> find(String path, String matcher) {
        List<File> files = new ArrayList<File>();

        File root = new File(path);
        File[] list = root.listFiles();

        if (list == null)
            return files;

        for (File file : list) {
            if (file.getName().matches(matcher)) {
                files.add(file);// ww w  . j a v  a  2 s.c om
            }
            if (file.isDirectory()) {
                files.addAll(find(file.getAbsolutePath(), matcher));
            }
        }

        return files;
    }
}

Related

  1. find(final File fileDir, final String fileNameRegex)
  2. find(final File root, final String name)
  3. find(String _sSourceString, String _sReg, int group)
  4. find(String executable, File... dirs)
  5. find(String name, File dir)
  6. find(String path, String suffix)
  7. find2(File baseDir, FileFilter filter, List files, boolean includeHiddenFiles)
  8. findByExt(File base, String ext)
  9. findByExtension(final File directory, final String extension)