public static int readUnsignedVarint(ByteBuffer buffer) throws IOException {
  int val=0;
  int bits=0;
  while (true) {
    final int data=buffer.get();
    val|=(data & 0x7F) << bits;
    if ((data & 0x80) == 0) {
      return val;
    }
    bits+=7;
    if (bits > 35) {
      throw new IOException("Variable length quantity is too long for expected integer.");
    }
  }
}

public static int readUnsignedVarint ( ByteBuffer buffer ) throws IOException { int val = 0 ; int bits = 0 ; while ( true ) { final int data = buffer . get ( ) ; val |= ( data & 0x7F ) << bits ; if ( ( data & 0x80 ) == 0 ) { return val ; } bits += 7 ; if ( bits > 35 ) { throw new IOException ( "Variable length quantity is too long for expected integer." ) ; } } }
read an unsigned integer .
