Java Folder Read getFiles(File dir, File... excludes)

Here you can find the source of getFiles(File dir, File... excludes)

Description

get Files

License

Open Source License

Declaration

public static List<String> getFiles(File dir, File... excludes) 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.io.File;

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    public static List<String> getFiles(File dir, File... excludes) {
        List<String> result = new ArrayList<String>();
        File[] aFiles = dir.listFiles();
        List<File> files = Arrays.asList(aFiles);
        for (File file : files) {
            boolean exclude = false;
            for (File f : excludes) {
                if (file.getAbsolutePath().startsWith(f.getAbsolutePath())) {
                    exclude = true;//w  w  w.  j  a  va2  s  .  c  o  m
                    break;
                }
            }
            if (!exclude) {
                result.add(file.getAbsolutePath());
                if (!file.isFile()) {
                    List<String> deeperList = getFiles(file, excludes);
                    result.addAll(deeperList);
                }
            }
        }
        return result;
    }
}

Related

  1. getFiles(File apkFile, Pattern regex)
  2. getFiles(File archive)
  3. getFiles(File dir)
  4. getFiles(File dir)
  5. getFiles(File dir)
  6. getFiles(File dir, final String pattern)
  7. getFiles(File dir, String... names)
  8. getFiles(File directory)
  9. getFiles(File directory)