Here you can find the source of byteToHex(byte[] base)
public static String byteToHex(byte[] base)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w. ja va 2 s .co m * Encodes a byte array (into what i forgot) * * @param base * @return */ //TODO compare the outcome of the above methods with this and eliminate the worst private static final char[] TOHEX = "0123456789abcdef".toCharArray(); public static String byteToHex(byte[] base) { char[] c = new char[base.length * 2]; int i = 0; for (byte b : base) { int j = b; j = j + 128; c[i++] = TOHEX[j / 0x10]; c[i++] = TOHEX[j % 0x10]; } return new String(c); } }