Here you can find the source of writeVarLong(long n, ByteBuffer buff)
Parameter | Description |
---|---|
n | the long to encode |
public static void writeVarLong(long n, ByteBuffer buff)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { /**//from w w w . j a va 2 s .c o m * Writes a signed long with the "VarInt" format. * * @param n the long to encode */ public static void writeVarLong(long n, ByteBuffer buff) { while ((n & 0xFFFF_FFFF_FFFF_FF80l) != 0) {// While we have more than 7 bits (0b0xxxxxxx) byte data = (byte) (n | 0x80);// Discard bit sign and set msb to 1 (VarInt byte prefix). buff.put(data); n >>>= 7; } buff.put((byte) n); } }