Here you can find the source of writePackedLong(ByteBuffer output, long value)
public static int writePackedLong(ByteBuffer output, long value)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int writePackedLong(ByteBuffer output, long value) { assert value >= 0; // int position = output.position(); while (value > 127) { output.put((byte) ((value & 127) + ((value > 127 ? 1 : 0) << 7))); value >>= 7;/*from w w w . j a va2 s. c om*/ } output.put((byte) (value & 127)); return position; } }