Here you can find the source of toHex(byte[] bytes)
public static final String toHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] hexDigits = "0123456789abcdef" .toCharArray();/* w ww . j a va2 s . c o m*/ public static final String toHex(byte[] bytes) { StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } }