public static int putAsShort(ByteBuffer buf, int index, int val) {
    buf.put(index + 1, (byte) val);
    val >>= 8;
    buf.put(index, (byte) val);
    return index + Bytes.SIZEOF_SHORT;
  }
Put a short value out to the given ByteBuffer's current position in big-endian format. This
also advances the position in buffer by short size.
@param buffer the ByteBuffer to write to
@param val    short to write out
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java