Java tutorial
//package com.java2s; import java.util.Locale; public class Main { /** * Convert byte array to hex string * * @param bytes * @return */ public static String bytesToHex(byte[] bytes) { StringBuilder sbuf = new StringBuilder(); for (int idx = 0; idx < bytes.length; idx++) { int intVal = bytes[idx] & 0xff; if (intVal < 0x10) sbuf.append("0"); sbuf.append(Integer.toHexString(intVal).toUpperCase(Locale.US)); } return sbuf.toString(); } }