List of utility methods to do Byte Array to String Convert
void | byteArray(StringBuilder buffer, byte[] bytes) byte Array for (int i = 0; i < bytes.length; i++) { buffer.append("b[").append(i).append("]=").append(bytes[i]); if (i < bytes.length - 1) { buffer.append(','); |
int | byteArrayToInt(byte[] value, int offset) byte Array To Int return (int) (((int) value[0 + offset] << 24) & 0xFF000000) | (((int) value[1 + offset] << 16) & 0x00FF0000) | (((int) value[2 + offset] << 8) & 0x0000FF00) | ((int) value[3 + offset] & 0x000000FF); |
short | byteArrayToShort(byte[] value, int offset) byte Array To Short return (short) ((((short) value[0 + offset] << 8) & 0xFF00) | ((short) value[1 + offset] & 0x00FF)); |
String | byteArrayToString(byte[] data) Returns a (readable) String representation of the byte array StringBuilder sb = new StringBuilder(); for (byte b : data) { sb.append(Integer.toString(b)); return sb.toString(); |
String | byteArrayToString(byte[] data) byte Array To String return new String(Hex.encodeHex(data)); |
String | writeByteArray(byte[] bytes) write Byte Array StringBuilder raw = new StringBuilder(String.format(Locale.US, "len %d: ", bytes.length)); for (int i = 0; i < bytes.length; i++) raw.append(String.format(Locale.US, "%X ", bytes[i])); return raw.toString(); |