Java Directory to File List getAllFilesRecursively(File directory, Collection files)

Here you can find the source of getAllFilesRecursively(File directory, Collection files)

Description

Helper for getAllSubdirectories(directory).

License

Creative Commons License

Declaration

private static void getAllFilesRecursively(File directory, Collection<File> files) 

Method Source Code

//package com.java2s;
/** //from  w  w  w  .  j  a  v a2  s . c o m
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools).
It is licensed under the Creative Commons Attribution License 
(see http://creativecommons.org/licenses/by/3.0) by 
the YAGO-NAGA team (see http://mpii.de/yago-naga)
    
Some utility methods for arrays
*/

import java.io.File;

import java.util.Collection;

public class Main {
    /**
     * Helper for getAllSubdirectories(directory).
     */
    private static void getAllFilesRecursively(File directory, Collection<File> files) {

        for (File file : directory.listFiles()) {
            if (file.isDirectory()) {
                getAllFilesRecursively(file, files);
            } else {
                files.add(file);
            }
        }
    }
}

Related

  1. getAllFilesLeastRecentFirst(File directory)
  2. getAllFilesMatching(File srcDir, final String regex)
  3. getAllFilesMatchingThisPatternIgnoreCase(String sDirectoryPath, String sPattern)
  4. getAllFilesPresentInFolder(File srcPath)
  5. getAllFilesRecursively(File dir, List filelist)
  6. getAllFilesWithExtension(String directory, final String extension)
  7. getAllFilesWithExtension(String folderPath, String extension)
  8. getAllFilesWithFilter(String DirectoryName, FilenameFilter Filter)