List of utility methods to do Byte Array to Hex Convert
String[] | toHexStringArray(byte[] bytes) to Hex String Array String[] result = new String[bytes.length]; for (int i = 0; i < bytes.length; i++) { result[i] = toHexString(bytes[i]); return result; |
String | convertToHex(byte[] data) convert To Hex StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { int halfByte = (data[i] >>> 4) & 0x0F; int twoHalves = 0; do { if ((0 <= halfByte) && (halfByte <= 9)) buf.append((char) ('0' + halfByte)); else ... |
String | convertToHex(byte[] data) convert To Hex StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { int halfbyte = (data[i] >>> 4) & 0x0F; int two_halfs = 0; do { if ((0 <= halfbyte) && (halfbyte <= 9)) buf.append((char) ('0' + halfbyte)); else ... |
String | convertToHex(byte[] data) convert To Hex StringBuilder buf = new StringBuilder(); for (int i = 0; i < data.length; i++) { int halfbyte = (data[i] >>> 4) & 0x0F; int two_halfs = 0; do { if ((0 <= halfbyte) && (halfbyte <= 9)) { buf.append((char) ('0' + halfbyte)); } else { ... |
String | convertToHexString(byte[] b) convert To Hex String StringBuilder sb = new StringBuilder(b.length * 2); for (byte a : b) { sb.append(HEX_DIGITS[(a & 0xf0) >>> 4]); sb.append(HEX_DIGITS[a & 0x0f]); return sb.toString(); |
String | encodeHex(byte[] data) encode Hex int l = data.length; char[] out = new char[l << 1]; for (int i = 0, j = 0; i < l; i++) { out[j++] = DIGITS[(0xF0 & data[i]) >>> 4]; out[j++] = DIGITS[0x0F & data[i]]; return new String(out); |
String | encodeHex(byte[] data) encode Hex StringBuilder sb = new StringBuilder(data.length * 2); Formatter formatter = new Formatter(sb); for (byte b : data) { formatter.format("%02x", b); return sb.toString(); |
String | convertToHex(byte[] data) Get the stuff and convert it to Hex. StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { int halfbyte = (data[i] >>> 4) & 0x0F; int two_halfs = 0; do { if ((0 <= halfbyte) && (halfbyte <= 9)) buf.append((char) ('0' + halfbyte)); else ... |
String | byteArrayToHexString(byte[] array) byte Array To Hex String StringBuffer hexString = new StringBuffer(); for (byte b : array) { int intVal = b & 0xff; if (intVal < 0x10) hexString.append("0"); hexString.append(Integer.toHexString(intVal)); return hexString.toString(); ... |
String | byteArrayToHexString(byte[] b) byte Array To Hex String String result = ""; for (int i = 0; i < b.length; i++) { result += Integer.toString((b[i] & 0xff) + 0x100, 16) .substring(1); return result; |