public class ByteUtils extends Object
Modifier and Type | Field and Description |
---|---|
static char[] |
HEX_DIGIT
Contains all the hex characters - used to lookup from utility methods.
|
Constructor and Description |
---|
ByteUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
bytesToChar(byte[] b)
Deprecated.
Should be replaced by
bytesToChars(byte[]) . |
static char[] |
bytesToChars(byte[] bytes)
Convert an array of bytes to their respective hex encoded characters.
|
static String |
bytesToHex(byte[] b)
Convert an array of bytes to their respective hex-octet encoded characters.
|
static char |
byteToChar(byte b)
Convert a byte to its respective hex encoded character.
|
static String |
byteToHex(byte b)
Convert a byte to its respective string of hex-octet encoded characters.
|
static byte[] |
charsToBytes(char[] chars)
Convert hex encoded characters to their respective bytes.
|
static byte |
charToByte(char c)
Convert a hex encoded character to its respective byte.
|
static byte[] |
codeBCD(byte[] uncoded)
Codes an array bytes to BCD coded bytes.
|
static byte[] |
decodeBCD(byte[] coded)
Decodes an array of BCD coded bytes.
|
static byte |
hexToByte(char high,
char low)
Convert two hex-coded characters to their respective byte
|
static byte[] |
hexToBytes(String s)
Convert a string of hex-octet encoded characters to their respective array of bytes.
|
static boolean |
isEmpty(byte[] array)
Checks if an array of primitive bytes is empty or
null . |
static boolean |
isEmpty(char[] array)
Checks if an array of primitive chars is empty or
null . |
static boolean |
isEmpty(Object[] array)
Checks if an array is empty or
null . |
public static final char[] HEX_DIGIT
public static byte[] decodeBCD(byte[] coded)
coded
- the array of BCD coded bytespublic static byte[] codeBCD(byte[] uncoded)
uncoded
- the array of bytes to codepublic static char byteToChar(byte b)
b
- the byte to convertpublic static byte charToByte(char c)
c
- the character to convertpublic static String byteToHex(byte b)
b
- the byte to convertpublic static byte hexToByte(char high, char low)
high
- the 4 high level bitslow
- the 4 low level bitspublic static String bytesToChar(byte[] b)
bytesToChars(byte[])
.b
- the byte array to convertbyteToChar(byte)
public static char[] bytesToChars(byte[] bytes)
bytes
- the byte array to convertbyteToChar(byte)
public static byte[] charsToBytes(char[] chars)
chars
- the byte array to convertcharToByte(char)
public static String bytesToHex(byte[] b)
b
- the byte array to convertbyteToHex(byte)
public static byte[] hexToBytes(String s)
s
- the hex encoded charactershexToByte(char, char)
public static boolean isEmpty(char[] array)
Checks if an array of primitive chars is empty or null
.
array
- the array to testtrue
if the array is empty or null
public static boolean isEmpty(byte[] array)
Checks if an array of primitive bytes is empty or null
.
array
- the array to testtrue
if the array is empty or null
public static boolean isEmpty(Object[] array)
Checks if an array is empty or null
.
array
- the array to testtrue
if the array is empty or null
Copyright © 2017 Nets Branch Norway. All Rights Reserved.