code: private FileStatus[] iterativeListing(String src) throws IOException {
      // fetch the first batch of entries in the directory
      DirectoryListing thisListing = namenode.getPartialListing(
          src, HdfsFileStatus.EMPTY_NAME);
  
      if (thisListing == null) { // the directory does not exist
        return null;
       }
      HdfsFileStatus[] partialListing = thisListing.getPartialListing();
      if (!thisListing.hasMore()) { // got all entries of the directory
        FileStatus[] stats = new FileStatus[partialListing.length];
        for (int i = 0; i < partialListing.length; i++) {
          stats[i] = HdfsFileStatus.toFileStatus(partialListing[i], src);
        }
        return stats;
      }
  
      // The directory size is too big that it needs to fetch more
      // estimate the total number of entries in the directory
      int totalNumEntries =
        partialListing.length + thisListing.getRemainingEntries();
      ArrayList<FileStatus> listing =
        new ArrayList<FileStatus>(totalNumEntries);
      // add the first batch of entries to the array list
      for (HdfsFileStatus fileStatus : partialListing) {
        listing.add(HdfsFileStatus.toFileStatus(fileStatus, src));
      }
  
      // now fetch more entries
      do {
        thisListing = namenode.getPartialListing(src, thisListing.getLastName());
  
        if (thisListing == null) {
          return null; // the directory is deleted
        }
  
        partialListing = thisListing.getPartialListing();
        for (HdfsFileStatus fileStatus : partialListing) {
          listing.add(HdfsFileStatus.toFileStatus(fileStatus, src));
        }
      } while (thisListing.hasMore());
  
      return listing.toArray(new FileStatus[listing.size()]);
    }
docs: List the given path iteratively if the directory is large
  
  @param src a path
  @return a listing of the path
  @throws IOException if any IO error is occurred