bytearray - how to convert bit array into hex contanning 8bits in java -
i have binary array converted hex using
stringbuilder sb = new stringbuilder(); (byte b : bytes) { sb.append(string.format("%02x ", b)); } system.out.println(sb.tostring());
but gives me hex code respective bit.
i want hex containing 8bits. please me.
you want this-
biginteger bint = new biginteger(1, bytes); string hexstring = string.format("%0" + (bytes.length << 1) + "x", bint);
for lower case hex digits, can use-
string hexstring = string.format("%0" + (bytes.length << 1) + "x", bint);
Comments
Post a Comment