Here you can find the source of toHexString(byte[] b)
Parameter | Description |
---|---|
b | Input bytes. |
public static String toHexString(byte[] b)
//package com.java2s; //License from project: Open Source License public class Main { static final char[] HEX_CHARS = "0123456789abcdef".toCharArray(); /**//ww w . ja v a 2 s . c o m * Convert bytes to hex string (all lower-case). * * @param b * Input bytes. * @return Hex string. */ public static String toHexString(byte[] b) { StringBuilder sb = new StringBuilder(b.length << 2); for (byte x : b) { int hi = (x & 0xf0) >> 4; int lo = x & 0x0f; sb.append(HEX_CHARS[hi]); sb.append(HEX_CHARS[lo]); } return sb.toString().trim(); } }