Here you can find the source of toHex(byte[] b)
public static String toHex(byte[] b)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. j a v a 2 s . com * Like DataHelper.toHexString but ensures no loss of leading zero bytes * @since 0.8.4 */ public static String toHex(byte[] b) { StringBuilder buf = new StringBuilder(40); for (int i = 0; i < b.length; i++) { int bi = b[i] & 0xff; if (bi < 16) buf.append('0'); buf.append(Integer.toHexString(bi)); } return buf.toString(); } }