Here you can find the source of byte2hex(byte[] bytes)
private static String byte2hex(byte[] bytes)
//package com.java2s; public class Main { private static String byte2hex(byte[] bytes) { StringBuilder sign = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i] & 0xFF); if (hex.length() == 1) { sign.append("0"); }//from www . j a v a2 s.c o m sign.append(hex.toUpperCase()); } return sign.toString(); } }