title: how to explore all sub directories with Java 8?
body: <p>I want to get all directories &amp; sub directories starting from current one.</p>
  
  <p>I found one approach to achieve this with <code>flatMap()</code>. But it has one level deep:</p>
  
  <pre><code>    List&lt;File&gt; files =
              Stream.of(new File(".").listFiles())
                      .flatMap(file -&gt; file.listFiles() == null ?
                              Stream.of(file) : Stream.of(file.listFiles()))
                      .collect(toList());
      System.out.println("Count: " + files.size());
      files.forEach(path -&gt; System.out.println("Path: " + path));
  </code></pre>
  
  <p>If I'll have next project struckture:</p>
  
  <p><a href="https://i.stack.imgur.com/ypm5p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ypm5p.png" alt="enter image description here"></a></p>
  
  <p>it will show just:</p>
  
  <blockquote>
    <p>Path: ./test/next1</p>
  </blockquote>
  
  <p><strong><em>How to achieve this with Java 1.8 full and deep as follows</em></strong></p>
  
  <blockquote>
    <p>Path: ./test/next1/next2/next3</p>
  </blockquote>