Here you can find the source of byteToHex(byte[] buffer)
public static String byteToHex(byte[] buffer)
//package com.java2s; //License from project: Apache License public class Main { public static String byteToHex(byte[] buffer) { StringBuffer hexString = new StringBuffer(); String hex;/* w w w . j a va2 s .c om*/ int iValue; for (int i = 0; i < buffer.length; i++) { iValue = buffer[i]; if (iValue < 0) iValue += 256; hex = Integer.toString(iValue, 16); if (hex.length() == 1) hexString.append("0" + hex); else hexString.append(hex); } return hexString.toString().toUpperCase(); } }