Here you can find the source of toHexString(byte[] buf, int offset, int length)
public static String toHexString(byte[] buf, int offset, int length)
//package com.java2s; public class Main { public static String toHexString(byte[] buf, int offset, int length) { StringBuilder output = new StringBuilder(); for (int i = offset; i < length; i++) { String strHex = Integer.toHexString(buf[offset + i] & 0xFF); if (strHex.length() < 2) { output.append('0'); }//from www . j av a 2 s . co m output.append(strHex); output.append(' '); } output.deleteCharAt(output.length() - 1); return output.toString().toUpperCase(); } }