Java tutorial
//package com.java2s; public class Main { public static String getHexString(byte[] messageid) { StringBuffer sb = new StringBuffer(); if (messageid.length > 0) { for (byte b : messageid) { sb.append(String.format("%02X", b)); } } return sb.toString(); } }