public final class ByteArrays extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_SIZE_IN_BITS |
static int |
BYTE_SIZE_IN_BYTES |
static int |
INET4_ADDRESS_SIZE_IN_BYTES |
static int |
INET6_ADDRESS_SIZE_IN_BYTES |
static int |
INT_SIZE_IN_BYTES |
static int |
LONG_SIZE_IN_BYTES |
static int |
SHORT_SIZE_IN_BYTES |
Modifier and Type | Method and Description |
---|---|
static short |
calcChecksum(byte[] data) |
static byte[] |
clone(byte[] array) |
static byte |
getByte(byte[] array,
int offset) |
static Inet4Address |
getInet4Address(byte[] array,
int offset) |
static Inet4Address |
getInet4Address(byte[] array,
int offset,
ByteOrder bo) |
static Inet6Address |
getInet6Address(byte[] array,
int offset) |
static Inet6Address |
getInet6Address(byte[] array,
int offset,
ByteOrder bo) |
static int |
getInt(byte[] array,
int offset) |
static int |
getInt(byte[] array,
int offset,
ByteOrder bo) |
static long |
getLong(byte[] array,
int offset) |
static long |
getLong(byte[] array,
int offset,
ByteOrder bo) |
static MacAddress |
getMacAddress(byte[] array,
int offset) |
static MacAddress |
getMacAddress(byte[] array,
int offset,
ByteOrder bo) |
static short |
getShort(byte[] array,
int offset) |
static short |
getShort(byte[] array,
int offset,
ByteOrder bo) |
static byte[] |
getSubArray(byte[] array,
int offset) |
static byte[] |
getSubArray(byte[] array,
int offset,
int length) |
static byte[] |
parseByteArray(String hexString,
String separator) |
static byte[] |
reverse(byte[] array) |
static byte[] |
toByteArray(byte value) |
static byte[] |
toByteArray(InetAddress value) |
static byte[] |
toByteArray(InetAddress value,
ByteOrder bo) |
static byte[] |
toByteArray(int value) |
static byte[] |
toByteArray(int value,
ByteOrder bo) |
static byte[] |
toByteArray(long value) |
static byte[] |
toByteArray(long value,
ByteOrder bo) |
static byte[] |
toByteArray(MacAddress value) |
static byte[] |
toByteArray(MacAddress value,
ByteOrder bo) |
static byte[] |
toByteArray(short value) |
static byte[] |
toByteArray(short value,
ByteOrder bo) |
static String |
toHexString(byte[] array,
String separator) |
static String |
toHexString(byte[] array,
String separator,
int offset,
int length) |
static String |
toHexString(byte value,
String separator) |
static String |
toHexString(int value,
String separator) |
static String |
toHexString(int value,
String separator,
ByteOrder bo) |
static String |
toHexString(long value,
String separator) |
static String |
toHexString(long value,
String separator,
ByteOrder bo) |
static String |
toHexString(short value,
String separator) |
static String |
toHexString(short value,
String separator,
ByteOrder bo) |
static void |
validateBounds(byte[] arr,
int offset,
int len)
A utility method to validate arguments which indicate a part of an array.
|
public static final int BYTE_SIZE_IN_BYTES
public static final int SHORT_SIZE_IN_BYTES
public static final int INT_SIZE_IN_BYTES
public static final int LONG_SIZE_IN_BYTES
public static final int INET4_ADDRESS_SIZE_IN_BYTES
public static final int INET6_ADDRESS_SIZE_IN_BYTES
public static final int BYTE_SIZE_IN_BITS
public static byte[] reverse(byte[] array)
array
- public static byte getByte(byte[] array, int offset)
array
- offset
- public static byte[] toByteArray(byte value)
value
- public static String toHexString(byte value, String separator)
value
- separator
- public static short getShort(byte[] array, int offset)
array
- offset
- public static short getShort(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static byte[] toByteArray(short value)
value
- public static byte[] toByteArray(short value, ByteOrder bo)
value
- bo
- public static String toHexString(short value, String separator)
value
- separator
- public static String toHexString(short value, String separator, ByteOrder bo)
value
- separator
- bo
- public static int getInt(byte[] array, int offset)
array
- offset
- public static int getInt(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static byte[] toByteArray(int value)
value
- public static byte[] toByteArray(int value, ByteOrder bo)
value
- bo
- public static String toHexString(int value, String separator)
value
- separator
- public static String toHexString(int value, String separator, ByteOrder bo)
value
- separator
- bo
- public static long getLong(byte[] array, int offset)
array
- offset
- public static long getLong(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static byte[] toByteArray(long value)
value
- public static byte[] toByteArray(long value, ByteOrder bo)
value
- bo
- public static String toHexString(long value, String separator)
value
- separator
- public static String toHexString(long value, String separator, ByteOrder bo)
value
- separator
- bo
- public static MacAddress getMacAddress(byte[] array, int offset)
array
- offset
- public static MacAddress getMacAddress(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static byte[] toByteArray(MacAddress value)
value
- public static byte[] toByteArray(MacAddress value, ByteOrder bo)
value
- bo
- public static Inet4Address getInet4Address(byte[] array, int offset)
array
- offset
- public static Inet4Address getInet4Address(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static Inet6Address getInet6Address(byte[] array, int offset)
array
- offset
- public static Inet6Address getInet6Address(byte[] array, int offset, ByteOrder bo)
array
- offset
- bo
- public static byte[] toByteArray(InetAddress value)
value
- public static byte[] toByteArray(InetAddress value, ByteOrder bo)
value
- bo
- public static byte[] getSubArray(byte[] array, int offset, int length)
array
- offset
- length
- public static byte[] getSubArray(byte[] array, int offset)
array
- offset
- public static String toHexString(byte[] array, String separator)
array
- separator
- public static String toHexString(byte[] array, String separator, int offset, int length)
array
- separator
- offset
- length
- public static short calcChecksum(byte[] data)
data
- public static byte[] parseByteArray(String hexString, String separator)
hexString
- separator
- public static byte[] clone(byte[] array)
array
- public static void validateBounds(byte[] arr, int offset, int len)
arr
- offset
- len
- NullPointerException
- if the arr
is null.IllegalArgumentException
- if arr
is empty or len
is zero.ArrayIndexOutOfBoundsException
- if offset
or len
is negative,
or (offset
+ len
) is greater than or equal to arr.length
.Copyright © 2014. All Rights Reserved.