public static String[] lsDirectories(String directory) throws Exception {
  String[] tmp=ls(directory);
  ArrayList<String> files=new ArrayList<>();
  for (  String s : tmp) {
    if (isDirectory(directory + File.separator + s))     files.add(s);
  }
  return files.toArray(new String[files.size()]);
}

public static String [ ] lsDirectories ( String directory ) throws Exception { String [ ] tmp = ls ( directory ) ; ArrayList < String > files = new ArrayList < > ( ) ; for ( String s : tmp ) { if ( isDirectory ( directory + File . separator + s ) ) files . add ( s ) ; } return files . toArray ( new String [ files . size ( ) ] ) ; }
list the directories contained within a directory .
