public final class ByteUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHexstring(byte[] bytes,
String delimiter)
Converts bytes to a hex string.
|
static long |
bytesToUnsignedInt(byte[] bytes)
Converts a 4 byte array of unsigned bytes to unsigned int.
|
static long |
bytesToUnsignedMedium(byte[] bytes)
Converts a 3 byte array of unsigned bytes to unsigned int.
|
static int |
bytesToUnsignedShort(byte[] bytes)
Converts a 2 byte array of unsigned bytes to unsigned short.
|
static byte[] |
convertBigIntegerToNBytes(BigInteger bigInteger,
int numBytes)
Utility method to convert BigInteger to n element byte array.
|
static byte[] |
unsignedIntToBytes(Long unsignedInt)
Converts unsigned integer to a 4 byte array of unsigned bytes.
|
static byte[] |
unsignedMediumToBytes(Long unsignedInt)
Converts unsigned integer to a 3 byte array of unsigned bytes.
|
static byte[] |
unsignedShortToBytes(Integer unsignedShort)
Converts unsigned short to a 2 byte array of unsigned bytes.
|
public static String bytesToHexstring(byte[] bytes, String delimiter)
bytes
- bytes that needs to be converted to hexdelimiter
- string delimiter@Nullable public static byte[] convertBigIntegerToNBytes(@Nullable BigInteger bigInteger, int numBytes)
bigInteger
- big integer value that needs to be converted to bytenumBytes
- convert to number of bytespublic static long bytesToUnsignedInt(byte[] bytes)
bytes
- an array of 4 unsigned bytespublic static long bytesToUnsignedMedium(byte[] bytes)
bytes
- an array of 4 unsigned bytespublic static int bytesToUnsignedShort(byte[] bytes)
bytes
- an array of 2 unsigned bytespublic static byte[] unsignedIntToBytes(Long unsignedInt)
unsignedInt
- representing the unsigned integerpublic static byte[] unsignedMediumToBytes(Long unsignedInt)
unsignedInt
- representing the unsigned integerpublic static byte[] unsignedShortToBytes(Integer unsignedShort)
unsignedShort
- representing the unsigned shortCopyright © 2019 OpenDaylight. All rights reserved.