list all files in the folder and also sub folders
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2534632/list-all-files-from-a-directory-recursively-with-java">List all files from a directory recursively with Java</a>  </p>
</blockquote>



<p>How can i return a file array that include all files on the folder and also sub folders my method just work for folder and it doesn't include sub folders .</p>

<pre><code>public File[] listf(String directoryName) {

    // .............list file
    File directory = new File(directoryName);

    // get all the files from a directory
    File[] fList = directory.listFiles();

    for (File file : fList) {
        if (file.isFile()) {
            System.out.println(file.getAbsolutePath());
        } else if (file.isDirectory()) {
            listf(file.getAbsolutePath());
        }
    }
    System.out.println(fList);
    return fList;
}                        
</code></pre>
