public static List < File > listDirectories ( File root ) { List < File > result = new ArrayList <> ( ) ; File [ ] files = root . listFiles ( new DirectoryFileFilter ( ) ) ; if ( files != null ) result . addAll ( Arrays . asList ( files ) ) ; Collections . sort ( result , new FileNameComparator ( ) ) ; return result ; }
Lists directories located under a given file .