Here you can find the source of bytes2Hex(byte[] bts)
private static String bytes2Hex(byte[] bts)
//package com.java2s; //License from project: Apache License public class Main { private static String bytes2Hex(byte[] bts) { String des = ""; String tmp = null;//from w w w. j a v a 2 s . c o m for (int i = 0; i < bts.length; i++) { tmp = Integer.toHexString(bts[i] & 0xFF); if (tmp.length() == 1) { des = des + "0"; } des = des + tmp; } return des; } private static String toHexString(byte[] ba) { StringBuilder str = new StringBuilder(); for (int i = 0; i < ba.length; i++) { str.append(String.format("%x", new Object[] { Byte.valueOf(ba[i]) })); } return str.toString(); } }