Here you can find the source of bytesToHexString(byte[] data)
public static final String bytesToHexString(byte[] data)
//package com.java2s; //License from project: Apache License public class Main { public static final String bytesToHexString(byte[] data) { StringBuilder valueHex = new StringBuilder(); for (int i = 0, tmp; i < data.length; i++) { tmp = data[i] & 0xff;/*from w ww.j a va 2 s . c o m*/ if (tmp < 16) { valueHex.append(0); } valueHex.append(Integer.toHexString(tmp)); } return valueHex.toString(); } }