title: Unable to list files in hadoop
body: <p>I am new to hadoop.</p>
  
  <p>I am trying to list all files present in my hdfs with this recursive code.</p>
  
  <pre><code>public void list(String path) throws IOException {
      Path dirPath = new Path(path);
      FileStatus[] fileStatus = fileSystem.listStatus(dirPath);
      if(fileStatus != null) {
          for (FileStatus fs : fileStatus) {
              String name = fs.getPath().getName();
              if(fs.isDir()) {
                  System.out.println("dir --&gt; " + name);
                  list(dirPath.getName() + "/" + name);
              } else {
                  System.out.println("file --&gt; " + name);
              }
          }
      }
  }
  </code></pre>
  
  <p>However I am not getting the files list.</p>
  
  <p>Thanks in advance..</p>