public class Varint extends Object
Encodes signed and unsigned values using a common variable-length scheme, found for example in Google's Protocol Buffers. It uses fewer bytes to encode smaller values, but will use slightly more bytes to encode large values.
Signed values are further encoded using so-called zig-zag encoding in order to make them "compatible" with variable-length encoding.
Modifier and Type | Method and Description |
---|---|
static int |
readUnsignedVarInt(byte[] bytes)
Decodes a value using the variable-length encoding from
Google's Protocol Buffers
|
static byte[] |
writeUnsignedVarInt(int value)
Encodes a value using the variable-length encoding from
Google's Protocol Buffers.
|
public static byte[] writeUnsignedVarInt(int value)
value
- Value to encodepublic static int readUnsignedVarInt(byte[] bytes)
bytes
- Encoded byte arrayCopyright © 2018. All rights reserved.