Here you can find the source of toReadableHexString(byte[] array)
public static String toReadableHexString(byte[] array)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.DatatypeConverter; public class Main { public static String toReadableHexString(byte[] array) { String hex = DatatypeConverter.printHexBinary(array).toUpperCase(); String finalHex = ""; int temp = 0; for (char current : hex.toCharArray()) { if (temp == 2) { finalHex += " "; temp = 0;// w w w . ja va2 s.co m } finalHex += current; temp++; } return finalHex; } }