Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String bytesToHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length); String temp; for (int i = 0; i < bytes.length; i++) { temp = Integer.toHexString(0xFF & bytes[i]); if (temp.length() < 2) sb.append(0); sb.append(temp.toUpperCase()).append(" "); } return sb.toString(); } }