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

voidgetAllFilesRecursively(File directory, Collection files)
Helper for getAllSubdirectories(directory).
for (File file : directory.listFiles()) {
    if (file.isDirectory()) {
        getAllFilesRecursively(file, files);
    } else {
        files.add(file);
File[]getAllFilesWithExtension(String directory, final String extension)
get All Files With Extension
return getAllFilesWithExtension(new File(directory), extension);
IterablegetAllFilesWithExtension(String folderPath, String extension)
get All Files With Extension
File folder = new File(folderPath);
File[] files = folder.listFiles();
if (files == null) {
    return new ArrayList<>();
return Arrays.asList(files).stream()
        .filter(file -> file.isFile() && file.getName().toLowerCase().endsWith(extension.toLowerCase()))
        .collect(Collectors.toList());
...
String[]getAllFilesWithFilter(String DirectoryName, FilenameFilter Filter)
{ method
File TestFile = new File(DirectoryName);
return (getAllFilesWithFilter(TestFile, Filter));