List of utility methods to do Byte Array to Hex
void | bytetoHex(final byte data, final StringBuffer buffer) Transforms a byte to a hexadecimal string. int high = ((data & 0xf0) >> 4); int low = (data & 0x0f); buffer.append(HEX_CHARACTER[high]); buffer.append(HEX_CHARACTER[low]); |
String | byteToHex(int val) Very fast 8-bit int to hex conversion, with zero-padded output. return HEX_CONSTANTS[val & 0xff]; |
StringBuffer | byteToHex(int val, StringBuffer sb) byte To Hex sb.append(HEX_DIGITS[(val >> 4) & 0xf]); sb.append(HEX_DIGITS[val & 0xf]); return sb; |
String | byteToHexDisplayString(byte[] b) Converts byte array to a string representation of hex bytes for display purposes. if (null == b) return "(null)"; int hexVal; StringBuilder sb = new StringBuilder(b.length * 2 + 2); sb.append("0x"); for (byte aB : b) { hexVal = aB & 0xFF; sb.append(hexChars[(hexVal & 0xF0) >> 4]); ... |
int | byteToHexWord(byte in) byte To Hex Word byte[] table = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 }; int result = 0x0000; result = (table[(in & 0xF0) >>> 4]) << 8; result = (result & 0xFF00) | (table[in & 0x0F]); return result; |
String | byteToLowerHex(final byte b) Retrieves a string representation of the provided byte in hexadecimal. return BYTE_HEX_STRINGS[LOWER_CASE][b & 0xFF];
|
String | byteToTwoHexString(final byte data) Convert a byte to a String of two Hex characters, with leading zero. final StringBuffer buffer; final String strHex; buffer = new StringBuffer(); strHex = Integer.toHexString(data & 0xFF); if (strHex.length() == 0) { buffer.append("00"); } else if (strHex.length() == 1) { buffer.append("0"); ... |