Here you can find the source of toHexString(byte[] array)
public static String toHexString(byte[] array)
//package com.java2s; //License from project: Apache License public class Main { public static String toHexString(byte[] array) { if (array == null) { return ""; }//from ww w . j a va 2s. c o m StringBuilder sb = new StringBuilder(array.length * 2); for (byte byt : array) { int v = byt & 0xff; if (v < 16) { sb.append('0'); } sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(); } }