title: Files.walk skip directories
body: <p>I am trying to write a program the list files recursively in my external hd but there is this recycle bin folder that I don't have access to.  I want to skip the folder but can't seem to do it.</p>
  
  <p>Is there anything wrong with this code below?</p>
  
  <pre><code>public static void main(String[] args) throws Exception
  {
      String path = "K:\\";
  
      Files.walk(Paths.get(path))
              .filter(it -&gt; !it.toString().startsWith("K:\\$RECYCLE.BIN"))
              .filter(Files::isRegularFile)
              .forEach(System.out::println);
  }
  </code></pre>
  
  <p>It keeps giving me this error:</p>
  
  <pre><code>Exception in thread "main" java.io.UncheckedIOException java.nio.file.AccessDeniedException: K:\$RECYCLE.BIN\S-1-5-21-684815243-3314879918-332412784-1001
      at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:88)
      at java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:104)
      ...
  </code></pre>