Here you can find the source of toHexString(byte[] b)
public static String toHexString(byte[] b)
//package com.java2s; // Licensed under the Academic Free License version 3.0 public class Main { /**/*from w w w . j a v a 2 s .c o m*/ * Return hex string of bytes. */ public static String toHexString(byte[] b) { StringBuffer s = new StringBuffer(); for (int i = 0; i < b.length; ++i) s.append(byteToHexString(b[i])); return s.toString(); } /** * @return byte to two character hex string. */ public static String byteToHexString(int b) { String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) return "0" + s; else return s; } }