Java File List Load getFileList(File dir, String regex)

Here you can find the source of getFileList(File dir, String regex)

Description

get File List

License

Open Source License

Declaration

private static ArrayList<String> getFileList(File dir, String regex) throws Exception 

Method Source Code


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

import java.io.File;
import java.util.ArrayList;

public class Main {
    private static ArrayList<String> getFileList(File dir, String regex) throws Exception {
        ArrayList<String> fileList = new ArrayList<String>();
        File[] fs = dir.listFiles();
        for (int i = 0; i < fs.length; i++) {
            if (fs[i].isDirectory()) {
                fileList.addAll(getFileList(fs[i], regex));
            } else if (fs[i].isFile() && fs[i].getName().endsWith(regex)) {
                fileList.add(fs[i].getAbsolutePath());
            }// w w w .jav a2  s  . c  o  m
        }
        return fileList;
    }
}

Related

  1. getFileList(File dir, ArrayList list)
  2. getFileList(File dir, Set arrayList)
  3. getFileList(File dirFile, final String filenamePrefix)
  4. getFileList(File f)
  5. getFileList(File f, FileFilter filter, boolean recursive, boolean wantDirectory, boolean wantHidden, ArrayList list)
  6. getFileList(File file)