Here you can find the source of toHex(byte[] bytes)
public static String toHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public static String toHex(byte[] bytes) { StringBuilder hexBuilder = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { hexBuilder.append(Character.forDigit((bytes[i] >>> 4) & 0xf, 16)); hexBuilder.append(Character.forDigit(bytes[i] & 0xf, 16)); }/*from w ww .ja v a 2s .co m*/ return hexBuilder.toString(); } }