Here you can find the source of toHexString(byte[] b)
private static String toHexString(byte[] b)
//package com.java2s; public class Main { private static String toHexString(byte[] b) { return toHexString(b, b.length); }//from w w w .j a v a 2 s.c om private static String toHexString(byte[] b, int len) { StringBuilder s = new StringBuilder(); s.append("\""); for (int i = 0; i < len; i++) { if (i > 0) { s.append(" "); } s.append(String.format("%02x", b[i] & 0xFF)); } s.append("\""); return s.toString(); } }