code: private static void writeHeader(ByteBuffer buffer,
                                    int position,
                                    int val,
                                    boolean original) {
      buffer.put(position, (byte) ((val << 1) + (original ? 1 : 0)));
      buffer.put(position + 1, (byte) (val >> 7));
      buffer.put(position + 2, (byte) (val >> 15));
    }
docs: Write the length of the compressed bytes. Life is much easier if the
  header is constant length, so just use 3 bytes. Considering most of the
  codecs want between 32k (snappy) and 256k (lzo, zlib), 3 bytes should
  be plenty. We also use the low bit for whether it is the original or
  compressed bytes.
  @param buffer the buffer to write the header to
  @param position the position in the buffer to write at
  @param val the size in the file
  @param original is it uncompressed