List of utility methods to do Byte Array to Hex
void | bytesToHex(StringBuffer buff, byte[] src, int start, int end) bytes To Hex String groupSeparator = ""; for (int i = start; i < end; i = i + 2) { buff.append(groupSeparator); int group = ((src[i] << 8) & 0xff00) | ((src[i + 1]) & 0xff); buff.append(Integer.toHexString(group)); groupSeparator = ":"; |
String[] | bytesToUnsignedHexes(byte[] bytes) bytes To Unsigned Hexes String[] hexValues = new String[bytes.length]; for (int i = 0; i < bytes.length; i++) { hexValues[i] = Integer.toHexString(bytes[i] & 0xFF); return hexValues; |
byte | byteToBcd(byte src) byte To Bcd byte re = src; if (src <= 0x39 && src >= 0x30) re = (byte) (src - 0x30); else if (src <= 0x46 && src >= 0x41) re = (byte) (src - 0x37); else if (src <= 0x66 && src >= 0x61) re = (byte) (src - 0x57); return re; ... |
char[] | byteToHex(byte b) byte To Hex char[] hexChars = new char[2]; int v = b & MOST_SIGNIFICANT_MASK; hexChars[0] = hexArray[v >>> 4]; hexChars[1] = hexArray[v & LEAST_SIGNIFICANT_MASK]; return hexChars; |
char[] | byteToHex(byte b) byte To Hex int unsignedByte = (int) b - Byte.MIN_VALUE; return new char[] { unsignedIntToHex((unsignedByte >> 4) & 0xf), unsignedIntToHex(unsignedByte & 0xf) }; |
String | byteToHex(byte b[]) Converte um Array de Byte em uma String de Hex String retorno = new String(); for (int j = 0; j < b.length; j++) { int i = b[j] & 0xFF; if (i < 16) { retorno += "0" + (Integer.toHexString(i)).toUpperCase(); } else { retorno += (Integer.toHexString(i)).toUpperCase(); return retorno; |
String | byteToHex(byte b[]) byte To Hex if (b == null) { throw new IllegalArgumentException("Argument b ( byte array ) is null! "); String hs = ""; String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0xff); if (stmp.length() == 1) { ... |
String | byteToHex(byte bytes[]) byte To Hex char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; StringBuffer buf = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; ++i) { buf.append(hexDigits[(bytes[i] & 0xf0) >> 4]); buf.append(hexDigits[bytes[i] & 0x0f]); return buf.toString(); |
String | byteToHex(byte data) byte To Hex StringBuffer buf = new StringBuffer(); buf.append(toHexChar((data >>> 4) & 0x0F)); buf.append(toHexChar(data & 0x0F)); return buf.toString(); |
String | byteToHex(byte[] array) Converts a byte array to a hex string. StringBuilder buffer = new StringBuilder(); for (int i = 0; i < array.length; i++) { if ((array[i] & 0xff) < 0x10) { buffer.append("0"); buffer.append(Integer.toString(array[i] & 0xff, 16) + " "); return buffer.toString().trim(); ... |