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