Package com.hierynomus.protocol.commons
Class ByteArrayUtils
- java.lang.Object
-
- com.hierynomus.protocol.commons.ByteArrayUtils
-
public class ByteArrayUtils extends java.lang.Object
Utility functions for byte arrays.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayUtils()
-
Method Summary
Modifier and Type Method Description static boolean
equals(byte[] a1, int a1Offset, byte[] a2, int a2Offset, int length)
Check whether some part or whole of two byte arrays is equal, forlength
bytes starting at some offset.static byte[]
parseHex(java.lang.String hex)
Parse a hexadecimal string representation to a byte array.static java.lang.String
printHex(byte[] array)
Get a hexadecimal representation of the full byte array, with each octet separated by a space.static java.lang.String
printHex(byte[] array, int offset, int len)
Get a hexadecimal representation of a byte array starting atoffset
index forlen
bytes, with each octet separated by a space.static java.lang.String
toHex(byte[] array)
Get the hexadecimal representation of a byte array.static java.lang.String
toHex(byte[] array, int offset, int len)
Get the hexadecimal representation of a byte array starting atoffset
index forlen
bytes.
-
-
-
Method Detail
-
equals
public static boolean equals(byte[] a1, int a1Offset, byte[] a2, int a2Offset, int length)
Check whether some part or whole of two byte arrays is equal, forlength
bytes starting at some offset.- Parameters:
a1
-a1Offset
-a2
-a2Offset
-length
-- Returns:
true
orfalse
-
printHex
public static java.lang.String printHex(byte[] array)
Get a hexadecimal representation of the full byte array, with each octet separated by a space.- Parameters:
array
-- Returns:
- hex string, each octet delimited by a space
-
printHex
public static java.lang.String printHex(byte[] array, int offset, int len)
Get a hexadecimal representation of a byte array starting atoffset
index forlen
bytes, with each octet separated by a space.- Parameters:
array
-offset
-len
-- Returns:
- hex string, each octet delimited by a space
-
toHex
public static java.lang.String toHex(byte[] array)
Get the hexadecimal representation of a byte array.- Parameters:
array
-- Returns:
- hex string
-
toHex
public static java.lang.String toHex(byte[] array, int offset, int len)
Get the hexadecimal representation of a byte array starting atoffset
index forlen
bytes.- Parameters:
array
-offset
-len
-- Returns:
- hex string
-
parseHex
public static byte[] parseHex(java.lang.String hex)
Parse a hexadecimal string representation to a byte array.- Parameters:
hex
- The hexadecimal string- Returns:
- the parsed byte array
-
-