Here you can find the source of convertToHex(byte[] data)
private static String convertToHex(byte[] data)
//package com.java2s; public class Main { private static String convertToHex(byte[] data) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { int halfByte = (data[i] >>> 4) & 0x0F; int twoHalves = 0; do {//from w ww . j ava 2 s.com if ((0 <= halfByte) && (halfByte <= 9)) buf.append((char) ('0' + halfByte)); else buf.append((char) ('a' + (halfByte - 10))); halfByte = data[i] & 0x0F; } while (twoHalves++ < 1); } return buf.toString(); } }