List of utility methods to do Byte Array to Hex String
String | bytesToHexString(byte[] b) Convert a vector of bytes into a regularily formatted string of hexadecimal values. String space = " "; StringBuilder sb = new StringBuilder(); for (int index = 0; index < b.length; index++) { int tmp = b[index]; tmp &= 0xFF; sb.append("0x"); if (tmp < 16) sb.append(space); ... |
String | bytesToHexString(byte[] b, int length) Converts byte array to a string representation of hex bytes. StringBuilder sb = new StringBuilder(length * 2); for (int i = 0; i < length; i++) { int hexVal = b[i] & 0xFF; sb.append(hexChars[(hexVal & 0xF0) >> 4]); sb.append(hexChars[(hexVal & 0x0F)]); return sb.toString(); |
String | bytesToHexString(byte[] bArray) bytes To Hex String StringBuffer sb = new StringBuffer(bArray.length); String sTemp; for (int i = 0; i < bArray.length; i++) { sTemp = Integer.toHexString(0xFF & bArray[i]); if (sTemp.length() < 2) sb.append(0); sb.append(sTemp); return sb.toString(); |
String | bytesToHexString(byte[] bArray) bytes To Hex String StringBuffer sb = new StringBuffer(bArray.length); for (int i = 0; i < bArray.length; i++) { String sTemp = byteToHexString(bArray[i]); sb.append(sTemp.toUpperCase()); return sb.toString(); |
String | bytesToHexString(byte[] bs) bytes To Hex String if (bs == null || bs.length == 0) { return ""; StringBuffer str = new StringBuffer(bs.length * 4); for (int i = 0; i < bs.length; i++) { str.append(hex[(bs[i] >> 4) & 0x0f]); str.append(hex[bs[i] & 0x0f]); return str.toString(); |
String | bytesToHexString(byte[] buf) bytes To Hex String final String decimals = "0123456789ABCDEF"; if (buf == null) return null; char[] r = new char[buf.length * 2]; for (int i = 0; i < buf.length; ++i) { r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4); r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f); return new String(r); |
String | bytesToHexString(byte[] byteArray) bytes To Hex String StringBuilder sb = new StringBuilder(); for (byte b : byteArray) { sb.append(String.format("%02X ", b)); return sb.toString(); |
String | bytesToHexString(byte[] bytes) Creates a string of hexadecimal representation of bytes from an array of bytes, separated by white spaces if (bytes.length == 0) { return ""; char[] resultString = new char[bytes.length * 3]; int byteValue; for (int i = 0; i < bytes.length; i++) { byteValue = bytes[i] & ONE_BYTE_MASK; resultString[i * 3] = hexChars[byteValue >>> 4]; ... |
String | bytesToHexString(byte[] bytes) bytes To Hex String if (bytes == null) { return "null"; String ret = ""; StringBuffer buf = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { if (i > 0) { ret += ":"; ... |
String | bytesToHexString(byte[] bytes) bytes To Hex String char[] buf = new char[bytes.length * 2]; int radix = 1 << 4; int mask = radix - 1; for (int i = 0; i < bytes.length; i++) { buf[2 * i] = hexDigit[(bytes[i] >>> 4) & mask]; buf[2 * i + 1] = hexDigit[bytes[i] & mask]; return new String(buf); ... |