Java Utililty Methods Directory to File List

List of utility methods to do Directory to File List

Description

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

Method

ListgetAllFileNamesInDir(String folderName)
Gets the all file names in dir.
List<String> fileList = new ArrayList<String>();
File folder = new File(folderName);
if (folder.exists() && folder.isDirectory()) {
    File[] libs = folder.listFiles();
    for (File lib : libs) {
        fileList.add(lib.getPath());
return fileList;
String[]getAllFileNamesWithExtension(String directory, final String extension)
get All File Names With Extension
return getAllFileNamesWithExtension(new File(directory), extension);
ListgetAllFilePath(String filedir)
get All File Path
File f = new File(filedir);
List<File> l = new ArrayList<File>();
getFilePaths(f, l);
return l;
ListgetAllFiles(File dir)
get All Files
List<File> result = new ArrayList<>();
getAllFilesAux(dir, result);
return result;
File[]getAllFiles(File dir)
get All Files
if (!dir.isDirectory()) {
    throw new IllegalArgumentException();
Vector allFiles = new Vector();
extractFiles(dir, allFiles);
int size = allFiles.size();
File[] ret = new File[size];
for (int i = 0; i < size; i++) {
...
voidgetAllFiles(File dir, List fileList)
get All Files
File[] files = dir.listFiles();
for (File file : files) {
    fileList.add(file);
    if (file.isDirectory()) {
        getAllFiles(file, fileList);
booleangetAllFiles(File dir, List fileList)
get All Files
try {
    File[] files = dir.listFiles();
    for (File file : files) {
        fileList.add(file);
        if (file.isDirectory()) {
            System.out.println("directory:" + file.getCanonicalPath());
            getAllFiles(file, fileList);
        } else {
...
ListgetAllFiles(File dir, Pattern filter)
Gets all files below the given directory.
logger.entering("de.axelwernicke.mypod.util.FileUtils", "getAllFiles");
List<File> allFiles = new ArrayList<File>();
try {
    File[] files = dir.listFiles();
    int fileLength = files.length;
    for (int i = 0; i < fileLength; i++) {
        if (files[i].isDirectory()) {
            allFiles.addAll(getAllFiles(files[i], filter));
...
ListgetAllFiles(File directory)
get All Files
List<File> fileList = new ArrayList<File>();
File[] files = directory.listFiles();
if (files != null) {
    for (File file : files) {
        fileList.add(file);
        if (file.isDirectory()) {
            fileList.addAll(getAllFiles(file));
return fileList;
CollectiongetAllFiles(File directory)
Collects all non-directory files in the given input directory (recursively).
Collection<File> files = new LinkedList<File>();
getAllFilesRecursively(directory, files);
return files;