Here you can find the source of toHexString(byte[] data, int offset, int length)
private static String toHexString(byte[] data, int offset, int length)
//package com.java2s; public class Main { static final char[] HEXS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private static String toHexString(byte[] data, int offset, int length) { StringBuilder s = new StringBuilder(length * 2); int end = offset + length; int high_nibble; int low_nibble; for (int i = offset; i < end; i++) { high_nibble = (data[i] & 0xF0) >>> 4; low_nibble = (data[i] & 0x0F); s.append(HEXS[high_nibble]); s.append(HEXS[low_nibble]);/*from www .j ava 2 s .c o m*/ } return s.toString(); } private static String toHexString(byte byt) { String result = null; int high_nibble; int low_nibble; high_nibble = (byt & 0xF0) >>> 4; low_nibble = (byt & 0x0F); result = "" + HEXS[high_nibble] + HEXS[low_nibble]; return result; } }