Here you can find the source of bytesToHexString(byte[] data, int fromIndex, int toIndex)
public static String bytesToHexString(byte[] data, int fromIndex, int toIndex)
//package com.java2s; public class Main { private static final char[] hex = "0123456789abcdef".toCharArray(); public static String bytesToHexString(byte[] data) { return bytesToHexString(data, 0, data.length); }/*from w ww . j av a 2 s .co m*/ public static String bytesToHexString(byte[] data, int fromIndex, int toIndex) { StringBuilder sb = new StringBuilder(); for (int i = fromIndex; i < toIndex; i++) { sb.append(hex[(data[i] >> 4) & 0xf]); sb.append(hex[data[i] & 0xf]); } return sb.toString(); } }