Here you can find the source of convertToHex(byte[] raw)
private static String convertToHex(byte[] raw)
//package com.java2s; public class Main { private static final String HEX_DIGITS = "0123456789abcdef"; private static String convertToHex(byte[] raw) { final StringBuilder hex = new StringBuilder(raw.length * 2); for (final byte b : raw) { hex.append(HEX_DIGITS.charAt((b & 0xF0) >> 4)).append( HEX_DIGITS.charAt((b & 0x0F))); }// w ww .j a va 2 s .c om return hex.toString(); } }