public static void writeUnsignedVarint(ByteBuffer buffer,int val){
  while ((val & 0x7F) != val) {
    buffer.put((byte)((val & 0x7F) | 0x80));
    val>>>=7;
  }
  buffer.put((byte)(val & 0x7F));
}

public static void writeUnsignedVarint ( ByteBuffer buffer , int val ) { while ( ( val & 0x7F ) != val ) { buffer . put ( ( byte ) ( ( val & 0x7F ) | 0x80 ) ) ; val >>>= 7 ; } buffer . put ( ( byte ) ( val & 0x7F ) ) ; }
write an unsigned integer using a variable - length encoding . data is always written in 7 - bit little - endian , where the 8th bit is the continuation flag .
