Here you can find the source of toHexBytes(byte[] toBeConverted)
public static byte[] toHexBytes(byte[] toBeConverted)
//package com.java2s; //License from project: Apache License public class Main { static final byte[] HEX_BYTES = new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static byte[] toHexBytes(byte[] toBeConverted) { if (toBeConverted == null) { throw new NullPointerException("Parameter to be converted can not be null"); }/*from ww w . j av a 2 s . c o m*/ byte[] converted = new byte[toBeConverted.length * 2]; for (int i = 0; i < toBeConverted.length; i++) { byte b = toBeConverted[i]; converted[i * 2] = HEX_BYTES[b >> 4 & 0x0F]; converted[i * 2 + 1] = HEX_BYTES[b & 0x0F]; } return converted; } }