public static boolean iterateOnChildDirs ( File parentDir , FileIterator iterator ) { if ( parentDir == null ) { log . warn ( "Parent dir is null" ) ; return true ; } // verify that we can read dir. String message = verifyReadDir ( parentDir ) ; if ( message != null ) { log . warn ( message ) ; return true ; } File childs [ ] = parentDir . listFiles ( DIR_FILTER ) ; if ( childs == null ) { log . info ( "Parent dir:" + parentDir . getAbsolutePath ( ) + " do not have child dirs" ) ; return true ; } else { for ( File child : childs ) { boolean iteratorRet = iterator . iterate ( child ) ; if ( iteratorRet == false ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Iterator returns false. Iteration on:" + parentDir . getAbsolutePath ( ) + " stopped." ) ; } return false ; } } return true ; } }
Iterate only on the childs of the parent folder Iterates on the folder pased on parameter only if the content can be readed . Return false if the iterator returns false on a file .