private static File deleteDirRecursiveInternal(File dir, boolean failFast) {
        if (!dir.exists()) {
            return null;
        }

        File[] files = dir.listFiles();
        if (files == null) {
            return null;
        }
        for (File file : files) {
            if (file.isDirectory()) {
                File failed = deleteDirRecursiveInternal(file, failFast);
                if (failFast && failed != null) {
                    return failed;
                }
            }
            if (!file.delete()) {
                if (failFast && file.exists()) { // OK if file does not exist anymore (e.g. concurrent deletion)
                    return file;
                }
            }
        }
        if (!dir.delete()) {
            if (failFast && dir.exists()) { // OK if file does not exist anymore (e.g. concurrent deletion)
                return dir;
            }
        }
        return null;
    }
private static File deleteDirRecursiveInternal ( File dir , boolean failFast ) { if ( ! dir . exists ( ) ) { return null ; } File [ ] files = dir . listFiles ( ) ; if ( files == null ) { return null ; } for ( File file : files ) { if ( file . isDirectory ( ) ) { File failed = deleteDirRecursiveInternal ( file , failFast ) ; if ( failFast && failed != null ) { return failed ; } } if ( ! file . delete ( ) ) { if ( failFast && file . exists ( ) ) { return file ; } } } if ( ! dir . delete ( ) ) { if ( failFast && dir . exists ( ) ) { return dir ; } } return null ; }
@return File that could not be deleted (fail fast mode only)