Here you can find the source of bytesToHexString(byte[] data, int offset, int length)
public static String bytesToHexString(byte[] data, int offset, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String bytesToHexString(byte[] data, int offset, int length) { StringBuffer s = new StringBuffer(); for (int i = offset; i < offset + length; i++) { int b = data[i] >= 0 ? data[i] : 0x0100 + data[i]; s.append(HEX_DIGITS[b / 16]).append(HEX_DIGITS[b % 16]); }/*from w w w .jav a 2 s . c om*/ return s.toString(); } }