public static void addFilesRecursively ( File dir , Collection < File > fileCollection ) { log . debug ( "Adding files from {}" , dir . getPath ( ) ) ; File [ ] files = dir . listFiles ( ) ; for ( File file : files ) { if ( file . isDirectory ( ) ) addFilesRecursively ( file , fileCollection ) ; else { fileCollection . add ( file ) ; } } }
Adds all files in a directory and it s subdirectories to the supplied Collection .