code: public static BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks) {
      if (blocks == null) {
        return new BlockLocation[0];
      }
      int nrBlocks = blocks.locatedBlockCount();
      BlockLocation[] blkLocations = new BlockLocation[nrBlocks];
      if (nrBlocks == 0) {
        return blkLocations;
      }
      int idx = 0;
      for (LocatedBlock blk : blocks.getLocatedBlocks()) {
        assert idx < nrBlocks : "Incorrect index";
        DatanodeInfo[] locations = blk.getLocations();
        String[] hosts = new String[locations.length];
        String[] names = new String[locations.length];
        String[] racks = new String[locations.length];
        for (int hCnt = 0; hCnt < locations.length; hCnt++) {
          hosts[hCnt] = locations[hCnt].getHostName();
          names[hCnt] = locations[hCnt].getName();
          NodeBase node = new NodeBase(names[hCnt],
                                       locations[hCnt].getNetworkLocation());
          racks[hCnt] = node.toString();
        }
        blkLocations[idx] = new BlockLocation(names, hosts, racks,
                                              blk.getStartOffset(),
                                              blk.getBlockSize(),
                                              blk.isCorrupt());
        idx++;
      }
      return blkLocations;
    }
docs: Convert a LocatedBlocks to BlockLocations[]
  @param blocks a LocatedBlocks
  @return an array of BlockLocations