title: Looking for files of certain extension using lambda
body: <p>As an exercise, I decide to rewrite some code of mine to use lambda expression. The code should check if a given string is a path to a file with <code>.pdf</code> extension and then it should display all the files that meet this requirement. This so what I've already come up with:</p>
  
  <pre><code>Files.newDirectoryStream(Paths.get(args[0]), path -&gt; path.toFile()
                      .toString()
                      .endsWith(".pdf"))
                      .forEach(System.out::println);
  </code></pre>
  
  <p>This code fails at one point: it also displays directories. Could you tell me why the following code fails to compile?</p>
  
  <pre><code>Files.newDirectoryStream(Paths.get(args[0]), path -&gt; path.toFile()
                      .isFile()
                      .toString()
                      .endsWith(".pdf"))
                      .forEach(System.out::println);
  </code></pre>