code: public static void serialize(ByteBuffer out, int position, BloomKFilter bloomFilter)
    {
      /**
       * Serialized BloomKFilter format:
       * 1 byte for the number of hash functions.
       * 1 big endian int(to match OutputStream) for the number of longs in the bitset
       * big endian longs in the BloomKFilter bitset
       */
      ByteBuffer view = out.duplicate().order(ByteOrder.BIG_ENDIAN);
      view.position(position);
      view.put((byte) bloomFilter.k);
      view.putInt(bloomFilter.getBitSet().length);
      for (long value : bloomFilter.getBitSet()) {
        view.putLong(value);
      }
    }
docs: Serialize a bloom filter to a ByteBuffer. Does not mutate buffer position.
  
  @param out         output buffer to write to
  @param position    output buffer position
  @param bloomFilter BloomKFilter that needs to be seralized