Here you can find the source of toHexString(byte[] raw)
public static String toHexString(byte[] raw)
//package com.java2s; //License from project: Apache License public class Main { private static final String HEXES = "0123456789ABCDEF"; public static String toHexString(byte[] raw) { if (raw == null) { return null; }/*from w w w. j a v a 2s . c om*/ final StringBuilder hex = new StringBuilder(2 * raw.length); for (final byte b : raw) { hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))); } return hex.toString(); } public static String toHexString(byte b) { return new StringBuilder().append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))) .toString(); } }