Java tutorial
//package com.java2s; public class Main { public static String getHexStr(byte[] buffer) { String hexStr = ""; if (buffer != null) { for (byte b : buffer) { String temp = Integer.toHexString(b & 0xFF); if (temp.length() == 1) { hexStr += "0"; } hexStr += temp + " "; } } return hexStr.toUpperCase(); } }