Java tutorial
//package com.java2s; public class Main { public static String toHex(final byte[] b) { final StringBuffer sb = new StringBuffer(b.length * 3); for (int i = 0; i < b.length; ++i) { sb.append(Character.forDigit((b[i] & 0xF0) >> 4, 16)); sb.append(Character.forDigit(b[i] & 0xF, 16)); } return ((sb != null) ? sb.toString().toUpperCase() : null); } }