Here you can find the source of getAllFilesRecursively(File directory, Collection
private static void getAllFilesRecursively(File directory, Collection<File> files)
//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); } } } }