title: How to retrieve a list of directories QUICKLY in Java?
body: <p>Suppose a very simple program that lists out all the subdirectories of a given directory. Sound simple enough? Except the only way to list all subdirectories in Java is to use <a href="http://java.sun.com/javase/6/docs/api/java/io/FilenameFilter.html" rel="noreferrer">FilenameFilter</a> combined with <a href="http://java.sun.com/javase/6/docs/api/java/io/File.html#list(java.io.FilenameFilter)" rel="noreferrer">File.list()</a>. </p>
  
  <p>This works for the trivial case, but when the folder has say 150,000 files and 2 sub folders, it's silly waiting there for 45 seconds iterating through all the files and testing for file.isDirectory(). Is there a better way to list sub directories??</p>
  
  <hr>
  
  <p>PS. Sorry, please save the lectures on having too many files in the same directory. Our live environment has this as part of the requirement.</p>