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