Here you can find the source of readVInt(ByteBuffer bb)
public static int readVInt(ByteBuffer bb)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int readVInt(ByteBuffer bb) { return (int) readVLong(bb); }// w w w . j a v a 2 s. c o m public static int readVInt(ByteBuffer bb, int len, byte firstByte) { return (int) readVLong(bb, len, firstByte); } public static long readVLong(ByteBuffer bb) { byte firstByte = bb.get(); int len = decodeVNumSize(firstByte); return readVLong(bb, len, firstByte); } public static long readVLong(ByteBuffer bb, int len, byte firstByte) { if (len == 1) { return firstByte; } long l = 0; for (int idx = 0; idx < len - 1; idx++) { byte b = bb.get(); l = l << 8; l = l | (b & 0xFF); } return (isNegativeVNum(firstByte) ? ~l : l); } public static int decodeVNumSize(byte value) { if (value >= -112) { return 1; } else if (value < -120) { return -119 - value; } return -111 - value; } public static boolean isNegativeVNum(byte value) { return value < -120 || (value >= -112 && value < 0); } }