Java File List Load getFileList(File dir, Set arrayList)

Here you can find the source of getFileList(File dir, Set arrayList)

Description

Gets file list.

License

Apache License

Parameter

Parameter Description
dir the dir
arrayList the array list

Return

the file list

Declaration

public static boolean getFileList(File dir, Set<File> arrayList) 

Method Source Code


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

import java.io.*;

import java.util.HashSet;

import java.util.Set;

public class Main {
    /**/*from  w w w.  j av a  2s  . c o  m*/
     * Gets file list.
     *
     * @param dir       the dir
     * @param arrayList the array list
     * @return the file list
     */
    public static boolean getFileList(File dir, Set<File> arrayList) {
        return getFileList(dir, null, arrayList);
    }

    /**
     * Gets file list.
     *
     * @param dir    the dir
     * @param filter the filter
     * @param set    the set
     * @return the file list
     */
    public static boolean getFileList(File dir, FileFilter filter, Set<File> set) {
        if (dir == null || !dir.exists()) {
            return false;
        }
        if (set == null) {
            set = new HashSet<File>();
        }
        if (dir.isFile()) {
            return true;
        }

        File[] files = filter == null ? dir.listFiles() : dir.listFiles(filter);
        for (File f : files) {
            set.add(f);
            if (f.isDirectory()) {
                getFileList(f, filter, set);
                continue;
            }
        }
        return true;
    }
}

Related

  1. getFileList(File dir, ArrayList list)
  2. getFileList(File dir, String regex)
  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)