Here you can find the source of toHexString(byte[] bytes, String separator, boolean upperCase)
public static String toHexString(byte[] bytes, String separator, boolean upperCase)
//package com.java2s; public class Main { public static String toHexString(byte[] bytes, String separator, boolean upperCase) { StringBuilder hexString = new StringBuilder(); for (byte b : bytes) { String str = Integer.toHexString(0xFF & b); // SUPPRESS CHECKSTYLE if (upperCase) { str = str.toUpperCase(); }/*w w w.j a va2s . c o m*/ if (str.length() == 1) { hexString.append("0"); } hexString.append(str).append(separator); } return hexString.toString(); } }