Here you can find the source of bytesToHexString(byte[] values)
public static String bytesToHexString(byte[] values)
//package com.java2s; public class Main { final protected static char[] hexArray = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String bytesToHexString(byte[] values) { String hex = ""; for (int j = 0; j < values.length; j++) { hex += byteToHexString(values[j]); if (j < values.length - 1) hex += " "; }// w ww . ja v a 2 s. c om return hex; } public static String byteToHexString(byte value) { int unsigned = value & 0xFF; return "" + hexArray[unsigned >>> 4] + hexArray[unsigned & 0x0F]; } }