Here you can find the source of toHex(byte[] b, int off, int len, String separator)
public static String toHex(byte[] b, int off, int len, String separator)
//package com.java2s; //License from project: Open Source License public class Main { public static String toHex(int b) { String result = String.format("%02X", b & 0xFF); return result; }//from www . j a v a 2 s . c o m public static String toHex(byte b) { String result = String.format("%02X", b); return result; } public static String toHex(byte[] b) { return toHex(b, 0, b.length); } public static String toHex(byte[] b, int off, int len) { return toHex(b, off, len, ""); } public static String toHex(byte[] b, int off, int len, String separator) { StringBuilder result = new StringBuilder(); for (int i = 0; i < b.length && i < len; i++) { result.append(toHex(b[i])); if (i != b.length - 1) result.append(separator); } return result.toString(); } }