private void writeFile(String filename, List<RegionInfo> movedRegions) throws IOException {
    try (DataOutputStream dos =
      new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)))) {
      dos.writeInt(movedRegions.size());
      for (RegionInfo region : movedRegions) {
        Bytes.writeByteArray(dos, RegionInfo.toByteArray(region));
      }
    } catch (IOException e) {
      LOG.error("ERROR: Was Not able to write regions moved to output file but moved "
        + movedRegions.size() + " regions", e);
      throw e;
    }
  }
Write the number of regions moved in the first line followed by regions moved in subsequent
lines
hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionMover.java