void serialize(DataOutputStream outputStream) throws IOException {
    HFile.checkFormatVersion(majorVersion);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream baosDos = new DataOutputStream(baos);

    BlockType.TRAILER.write(baosDos);
    serializeAsPB(baosDos);

    // The last 4 bytes of the file encode the major and minor version universally
    baosDos.writeInt(materializeVersion(majorVersion, minorVersion));

    baos.writeTo(outputStream);
  }
Write the trailer to a data stream. We support writing version 1 for testing and for
determining version 1 trailer size. It is also easy to see what fields changed in version 2.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/FixedFileTrailer.java