default int write(OutputStream out, boolean withTags) throws IOException {
    // Key length and then value length
    ByteBufferUtils.putInt(out, KeyValueUtil.keyLength(this));
    ByteBufferUtils.putInt(out, getValueLength());

    // Key
    PrivateCellUtil.writeFlatKey(this, out);

    if (getValueLength() > 0) {
      // Value
      out.write(getValueArray(), getValueOffset(), getValueLength());
    }

    // Tags length and tags byte array
    if (withTags && getTagsLength() > 0) {
      // Tags length
      out.write((byte) (0xff & (getTagsLength() >> 8)));
      out.write((byte) (0xff & getTagsLength()));

      // Tags byte array
      out.write(getTagsArray(), getTagsOffset(), getTagsLength());
    }

    return getSerializedSize(withTags);
  }
Write this cell to an OutputStream in a {@link KeyValue} format. <br>
KeyValue format <br>
<code>&lt;4 bytes keylength&gt; &lt;4 bytes valuelength&gt; &lt;2 bytes rowlength&gt;
&lt;row&gt; &lt;1 byte columnfamilylength&gt; &lt;columnfamily&gt; &lt;columnqualifier&gt;
&lt;8 bytes timestamp&gt; &lt;1 byte keytype&gt; &lt;value&gt; &lt;2 bytes tagslength&gt;
&lt;tags&gt;</code>
@param out      Stream to which cell has to be written
@param withTags Whether to write tags.
@return how many bytes are written.
hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java