Java tutorial
//package com.java2s; import java.util.Locale; public class Main { private static String _bytes2Hex(byte[] b) { StringBuilder builder = new StringBuilder(); String stmp = ""; for (int i = 0; i < b.length; i++) { stmp = Integer.toHexString(b[i] & 0xFF); if (stmp.length() == 1) { builder.append("0" + stmp); } else { builder.append(stmp); } } return builder.toString().toUpperCase(Locale.getDefault()); } }