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