Here you can find the source of toHexString(byte[] bytes)
public static String toHexString(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public static String toHexString(byte[] bytes) { StringBuilder builder = new StringBuilder(); for (byte b : bytes) { builder.append(Integer.toHexString((b >> 4) & 0xf)); builder.append(Integer.toHexString(b & 0xf)); }//from w w w .j av a2 s. c o m return builder.toString(); } public static String toHexString(byte[] bytes, int offset, int length) { return toHexString(copyOfRange(bytes, offset, length)); } public static byte[] copyOfRange(byte[] bytes, int offset, int len) { byte[] result = new byte[len]; System.arraycopy(bytes, offset, result, 0, len); return result; } }