List of utility methods to do Byte Array to Hex Convert
String | byte2hex(byte[] b) bytehex StringBuilder hs = new StringBuilder(); String stmp; for (int n = 0; b != null && n < b.length; n++) { stmp = Integer.toHexString(b[n] & 0XFF); if (stmp.length() == 1) hs.append('0'); hs.append(stmp); return hs.toString().toUpperCase(); |
String | byteArrayToHexString(byte[] b) byte Array To Hex String StringBuffer buf = new StringBuffer(); for (int i = 0; i < b.length; i++) { int j = b[i] & 0xFF; buf.append(hexDigits.charAt(j / 16)); buf.append(hexDigits.charAt(j % 16)); return buf.toString(); |
String | bytesToHexString(byte[] bytes) bytes To Hex String StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) { sb.append('0'); sb.append(hex); return sb.toString(); |
byte[] | hex2byte(byte[] b) hexbyte if ((b.length % 2) != 0) throw new IllegalArgumentException(); byte[] b2 = new byte[b.length / 2]; for (int n = 0; n < b.length; n += 2) { String item = new String(b, n, 2); b2[n / 2] = (byte) Integer.parseInt(item, 16); return b2; ... |
String | toHex(byte[] buf) to Hex if (buf == null) return ""; StringBuffer result = new StringBuffer(2 * buf.length); for (int i = 0; i < buf.length; i++) { appendHex(result, buf[i]); return result.toString(); |
String | toHex(byte[] data) Converts byte data to a Hex-encoded string. StringBuilder sb = new StringBuilder(data.length * 2); for (int i = 0; i < data.length; i++) { String hex = Integer.toHexString(data[i]); if (hex.length() == 1) { sb.append("0"); } else if (hex.length() == 8) { hex = hex.substring(6); sb.append(hex); return sb.toString().toLowerCase(Locale.getDefault()); |
String | toHexString(byte[] b) Convert a byte array to a hex string. StringBuffer sb = new StringBuffer(b.length * 2); for (int i = 0; i < b.length; i++) { sb.append(hexChar[(b[i] & 0xf0) >>> 4]); sb.append(hexChar[b[i] & 0x0f]); return sb.toString(); |
String | toHexString(byte[] buf, int offset, int length) to Hex String StringBuilder output = new StringBuilder(); for (int i = offset; i < length; i++) { String strHex = Integer.toHexString(buf[offset + i] & 0xFF); if (strHex.length() < 2) { output.append('0'); output.append(strHex); output.append(' '); ... |
String | toHexString(byte[] data) Converts a byte array into a String of its hexadecimal representation. int c; String res = "", s; for (byte aux : data) { c = aux & 0xff; s = Integer.toHexString(c); if (s.length() == 1) res += "0"; res += s; ... |
String | getHexString(byte[] b) get Hex String return getHexString(b, HEX_STRING_BLANK_SPLIT);
|