public static List < File > getDirectories ( File path ) { Check . notNull ( path ) ; return Optional . ofNullable ( path . listFiles ( ) ) . map ( files -> Arrays . asList ( files ) . stream ( ) . filter ( File :: isDirectory ) . collect ( Collectors . toList ( ) ) ) . orElseGet ( Collections :: emptyList ) ; }
Get all directories existing in the path .