Here you can find the source of toHexChars(byte[] bytes)
public static char[] toHexChars(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] HEX = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** Converts the given byte array to a hex character array. */ public static char[] toHexChars(byte[] bytes) { char[] hex = new char[bytes.length * 2]; for (int i = 0, j = 0; i < bytes.length; i++) { hex[j++] = HEX[(bytes[i] >> 4) & 0xF]; hex[j++] = HEX[bytes[i] & 0xF]; }//from w ww. j ava2s . c o m return hex; } }