Java Utililty Methods File List Load

List of utility methods to do File List Load

Description

The list of methods to do File List Load are organized into topic(s).

Method

voidgetFileList(File dir, ArrayList list)
get File List
if (dir == null || !dir.exists())
    return;
list.add(dir);
if (dir.isFile()) {
    return;
File[] files = dir.listFiles();
if (files == null)
...
booleangetFileList(File dir, Set arrayList)
Gets file list.
return getFileList(dir, null, arrayList);
ArrayListgetFileList(File dir, String regex)
get File List
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());
return fileList;
File[]getFileList(File dirFile, final String filenamePrefix)
get File List
File[] subFiles = dirFile.listFiles(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
        File f = new File(dir + File.separator + name);
        return f.isFile() && name.startsWith(filenamePrefix);
});
return subFiles;
...
ListgetFileList(File f)
Gets a list of files in the specified dir.
List<File> fileList = new ArrayList<File>();
File[] files = f.listFiles();
if (files != null) {
    for (File file : files) {
        if (!file.isDirectory())
            fileList.add(file);
return fileList;
voidgetFileList(File f, FileFilter filter, boolean recursive, boolean wantDirectory, boolean wantHidden, ArrayList list)
Get file list from specified directory applying the specified parameters
final File[] files = f.listFiles(filter);
if (files != null) {
    for (File file : files) {
        if ((!file.isHidden()) || wantHidden) {
            if (file.isDirectory()) {
                if (wantDirectory)
                    list.add(file);
                if (recursive)
...
File[]getFileList(File file)
Get complete list of files in folder
if (file.isFile() && !file.isDirectory()) {
    return new File[] { file };
return file.listFiles() != null ? file.listFiles() : new File[0];
CollectiongetFileList(File file)
get File List
return getFileList(file, true);
ListgetFileList(File file, String[] suffixs)
get File List
return getFileList(file, new ArrayList<File>(), suffixs, null, null);
ListgetFileList(File folder, String type)
get File List
List<File> fileNameList = new ArrayList<File>();
File[] files = folder.listFiles();
for (File file : files) {
    if (getFileType(file).equalsIgnoreCase(type)) {
        fileNameList.add(file);
return fileNameList;
...