Here you can find the source of toHex(byte[] raw)
public static String toHex(byte[] raw)
//package com.java2s; //License from project: Open Source License public class Main { public static String toHex(byte[] raw) { final String HEXES = "0123456789ABCDEF"; if (raw == null) { return null; }// w w w . j a v a 2 s .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))).append(" "); } return hex.toString(); } }