private boolean folderContainsFiles ( File folder ) { if ( folder != null ) { File [ ] files = folder . listFiles ( ) ; for ( File file : files ) if ( file . isFile ( ) ) return true ; for ( File file : files ) if ( file . isDirectory ( ) ) if ( folderContainsFiles ( file ) ) return true ; } return false ; }
Breadth - first traversal of folder and any subdirectories looking for if any files exist