Here you can find the source of readVarInt(ByteBuffer buffer)
public static int readVarInt(ByteBuffer buffer) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.ByteBuffer; public class Main { public static int readVarInt(ByteBuffer buffer) throws IOException { int i = 0; int j = 0; while (true) { int b0 = buffer.get(); i |= (b0 & 127) << j++ * 7; if (j > 5) { throw new IOException("VarInt too big"); }/*from www . j a va 2 s. c om*/ if ((b0 & 128) != 128) { break; } } return i; } }