title: Recursively list all files within a directory using nio.file.DirectoryStream;
body: <p>I want to list all the FILES within the specified directory and subdirectories within that directory. No directories should be listed.</p>
  
  <p>My current code is below. It does not work properly as it only lists the files and directories within the specified directory.</p>
  
  <p>How can I fix this?</p>
  
  <pre><code>final List&lt;Path&gt; files = new ArrayList&lt;&gt;();
  
  Path path = Paths.get("C:\\Users\\Danny\\Documents\\workspace\\Test\\bin\\SomeFiles");
  try
  {
    DirectoryStream&lt;Path&gt; stream;
    stream = Files.newDirectoryStream(path);
    for (Path entry : stream)
    {
      files.add(entry);
    }
    stream.close();
  }
  catch (IOException e)
  {
    e.printStackTrace();
  }
  
  for (Path entry: files)
  {
    System.out.println(entry.toString());
  }
  </code></pre>