Here you can find the source of toHexString(byte[] data)
private static String toHexString(byte[] data)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] hexCode = "0123456789abcdef".toCharArray(); private static String toHexString(byte[] data) { if (data == null) { return null; }/*w w w .j a va 2 s. c om*/ StringBuilder r = new StringBuilder(data.length * 2); for (byte b : data) { r.append(hexCode[(b >> 4) & 0xF]); r.append(hexCode[(b & 0xF)]); } return r.toString(); } }