public static boolean containsFile ( final File parent , final File search ) { boolean exists = false ; final String [ ] children = parent . list ( ) ; if ( children == null ) { return false ; } final List < String > fileList = Arrays . asList ( children ) ; if ( fileList . contains ( search . getName ( ) ) ) { exists = true ; } return exists ; }
Checks if the given file contains only in the parent file not in the subdirectories .