code: public RemoteIterator<LocatedBlockFileStatus> listPathWithBlockLocation(
        final String src) throws IOException {
      checkOpen();
      try {
        return new RemoteIterator<LocatedBlockFileStatus>() {
          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 LocatedBlockFileStatus next() throws IOException {
            if (!hasNext()) {
              throw new java.util.NoSuchElementException("No more entry in " + src);
            }
            return HdfsFileStatus.toLocatedBlockFileStatus(thisListing.getPartialListing()[i],
                thisListing.getBlockLocations()[i++], src);
          }
        };
      } catch(RemoteException re) {
        throw re.unwrapRemoteException(AccessControlException.class);
      }
    }
docs: Get a partial listing of the indicated directory
  
  Recommend to use HdfsFileStatus.EMPTY_NAME as startAfter
  if the application wants to fetch a listing starting from
  the first entry in the directory
  
  @see ClientProtocol#getLocatedPartialListing(String, byte[])