Here you can find the source of getVInt(ByteBuffer bf, int index)
public static final int getVInt(ByteBuffer bf, int index)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static final int getVInt(ByteBuffer bf, int index) { byte b = bf.get(index++); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = bf.get(index++);/*from w w w .j a v a 2 s .c o m*/ i |= (b & 0x7F) << shift; } return i; } public static final int getVInt(ByteBuffer bf) { byte b = bf.get(); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = bf.get(); i |= (b & 0x7F) << shift; } return i; } public static final int getVInt(byte[] b, int[] index) { int i = b[index[0]] & 0x7F; for (int shift = 7; (b[index[0]++] & 0x80) != 0; shift += 7) i |= (b[index[0]] & 0x7F) << shift; return i; } public static final int getVInt(byte[] b) { int i = b[0] & 0x7F; int j = 1; for (int shift = 7; j < b.length; shift += 7) i |= (b[j++] & 0x7F) << shift; return i; } public static final byte[] getVInt(int i) { byte[] tmp = new byte[5]; int j = 0; while ((i & ~0x7F) != 0) { tmp[j++] = (byte) ((i & 0x7f) | 0x80); i >>>= 7; } tmp[j++] = (byte) i; byte[] ret = new byte[j]; System.arraycopy(tmp, 0, ret, 0, j); return ret; } }