title: Number of subfolders in a folder directory
body: <p>I have a folder which consists of both datafiles (<code>.txt</code> etc) and subfolders.</p>
  
  <p>In Java, how would I accomplish getting the number of subfolders in any specified directory path?</p>
  
  <p>(so excluding the datafiles; only counting the subfolders)</p>
  
  <p>I have read about counting the number of <code>.txt</code> files but can't seem to find anything about counting subfolders only.</p>
  
  <p>I have no idea where to start but to give you an idea:</p>
  
  <pre><code>String directory = "C:\Users\ . \Desktop\ . \workspace\src\testfolder";
  int numberOfSubfolders;
  
  //what is numberOfSubfolders in testfolder?
  </code></pre>
  
  <p>All help appreciated. </p>