private void collectFiles ( final File folder , final List < File > found ) { File [ ] files = folder . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { collectFiles ( file , found ) ; } else if ( file . isFile ( ) && file . getPath ( ) . endsWith ( suffix ) ) { int index = 0 ; for ( String text : plainTexts ) { index = file . getPath ( ) . indexOf ( text , index ) ; if ( index == - 1 ) { break ; } else { index += text . length ( ) ; } } if ( index >= 0 ) { found . add ( file ) ; } } } } }
Collects files from a folder and all nested sub folders .