Here you can find the source of bytesToHex(byte[] data)
public static String bytesToHex(byte[] data)
//package com.java2s; public class Main { public static String bytesToHex(byte[] data) { if (data == null) { return null; }//from w w w . j a v a 2 s .c o m int len = data.length; String str = ""; for (int i = 0; i < len; i++) { if ((data[i] & 0xFF) < 16) str = str + "0" + java.lang.Integer.toHexString(data[i] & 0xFF); else str = str + java.lang.Integer.toHexString(data[i] & 0xFF); } return str; } }