code: private RemoteIterator<LocatedFileStatus> iteratorListing(final String src)
    throws IOException {
      return new RemoteIterator<LocatedFileStatus>() {
        private LocatedDirectoryListing thisListing;
        private int i;
  
        { // initializer
          // fetch the first batch of entries in the directory
  
          thisListing = namenode.getLocatedPartialListing(
              src, HdfsFileStatus.EMPTY_NAME);
          if (thisListing == null) { // the directory does not exist
            throw new FileNotFoundException("File " + src + " does not exist.");
          }
        }
  
        @Override
        public boolean hasNext() throws IOException {
          if (i>=thisListing.getPartialListing().length
              && thisListing.hasMore()) {
            // current listing is exhausted & fetch a new listing
            thisListing = namenode.getLocatedPartialListing(
                src, thisListing.getLastName());
            if (thisListing == null) {
              throw new FileNotFoundException("File " + src + " does not exist.");
            }
            i = 0;
          }
          return i < thisListing.getPartialListing().length;
        }
  
        @Override
        public LocatedFileStatus next() throws IOException {
          if (!hasNext()) {
            throw new java.util.NoSuchElementException("No more entry in " + src);
          }
          return HdfsFileStatus.toLocatedFileStatus(thisListing.getPartialListing()[i],
              thisListing.getBlockLocations()[i++], src);
        }
      };
  
    }
docs: create the iterator from the iterative listing with block locations