public static boolean containsFileRecursive ( final File parent , final File search ) { final File toSearch = search . getAbsoluteFile ( ) ; boolean exists = false ; final File [ ] children = parent . getAbsoluteFile ( ) . listFiles ( ) ; if ( children == null ) { return false ; } final List < File > fileList = Arrays . asList ( children ) ; for ( final File currentFile : fileList ) { if ( currentFile . isDirectory ( ) ) { exists = FileSearchExtensions . containsFileRecursive ( currentFile , toSearch ) ; if ( exists ) { return true ; } } if ( fileList . contains ( toSearch ) ) { return true ; } } return exists ; }
Checks if the given file contains only in the parent file recursively .