Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static String parseByte2HexStr(byte[] buf) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < buf.length; i++) { String hex = Integer.toHexString(buf[i] & 0XFF); if (hex.length() == 1) { // hex = '0' + hex; sb.append("0"); } sb.append(hex); } return sb.toString().toUpperCase(); } }