Here you can find the source of putVInt(ByteBuffer b, int i)
public static final int putVInt(ByteBuffer b, int i)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static final int putVInt(ByteBuffer b, int i) { int j = 0; while ((i & ~0x7F) != 0) { b.put((byte) ((i & 0x7f) | 0x80)); i >>>= 7;/*from w w w . j av a2 s. co m*/ j++; } b.put((byte) i); return ++j; } public static final int putVInt(byte[] b, int index, int i) { while ((i & ~0x7F) != 0) { b[index++] = (byte) ((i & 0x7f) | 0x80); i >>>= 7; } b[index++] = (byte) i; return index; } }