Here you can find the source of bytesToStrHex(byte[] bytes)
public static final String bytesToStrHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public static final String bytesToStrHex(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length); String sTemp;//from w w w . j a v a2 s.co m for (int i = 0; i < bytes.length; i++) { sTemp = Integer.toHexString(0xFF & bytes[i]); if (sTemp.length() < 2) sb.append(0); sb.append(sTemp.toUpperCase()); } return sb.toString(); } }