Java File Find find(File root)

Here you can find the source of find(File root)

Description

find

License

Apache License

Declaration

public static List<File> find(File root) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

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

public class Main {
    public static List<File> find(String root) {
        return find(new File(root));
    }/* w  w w .ja  va 2  s. c  o  m*/

    public static List<File> find(File root) {
        if (!root.isDirectory())
            throw new IllegalAccessError(root + " must be a folder.");

        List<File> klazzes = new ArrayList<File>();
        addFiles(klazzes, root);

        return klazzes;
    }

    private static void addFiles(List<File> files, File folder) {
        for (File f : folder.listFiles()) {
            if (f.isFile() && f.getName().endsWith(".class"))
                files.add(f);
            else if (f.isDirectory())
                addFiles(files, f);
        }
    }
}

Related

  1. find(File dir, String suffix, Set ignore)
  2. find(File file)
  3. find(File file, Pattern pattern, int limit, List found, Set visited)
  4. find(File folder, final String name)
  5. find(File path, Boolean recursive)
  6. find(final File fileDir, final String fileNameRegex)
  7. find(final File root, final String name)
  8. find(String _sSourceString, String _sReg, int group)
  9. find(String executable, File... dirs)