title: Java - Count all file extensions in a folder using DirectoryStream
body: <p>I would like to show all file extensions in a specific folder and give the total for each extension using <code>DirectoryStream</code>.</p>
  
  <p>Now I'm only showing all the files in that folder, but how do I get their extensions only instead?
  I should also get the extensions of these files and count the total for each extension in that folder (see output below).</p>
  
  <pre><code>public static void main (String [] args) throws IOException {
  
      Path path = Paths.get(System.getProperty("user.dir"));
  
      if (Files.isDirectory(path)){
          DirectoryStream&lt;Path&gt; directoryStream = Files.newDirectoryStream(path);
  
          for (Path p: directoryStream){
              System.out.println(p.getFileName());
          }
      } else {
          System.out.printf("Path was not found.");
      }
  }
  </code></pre>
  
  <p>The output should look like this.
  I suppose the best way to get this output is using lambdas?</p>
  
  <pre><code>FILETYPE    TOTAL
  ------------------
  CLASS    |  5
  TXT      |  10
  JAVA     |  30
  EXE      |  27
  </code></pre>