Here you can find the source of bytesToHex(byte[] data, int m, int n)
public static String bytesToHex(byte[] data, int m, int n)
//package com.java2s; //License from project: Open Source License public class Main { public static String bytesToHex(byte[] data, int m, int n) { char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; char[] temp = new char[n * 2]; int k = m + n; for (int l = m; l < k; l++) { byte b = data[l]; temp[l * 2] = hexDigits[b >>> 4 & 0x0f]; temp[l * 2 + 1] = hexDigits[b & 0x0f]; }/* w w w . ja v a 2 s. c om*/ return new String(temp); } public static String bytesToHex(byte[] data) { return bytesToHex(data, 0, data.length); } }