Java tutorial
//package com.java2s; public class Main { public static final int EventIDNotificationAdded = 0; public static final int FIRST_BITMASK = 1; public static final int SECOND_BITMASK = 2; public static String toHexCode(byte[] data) { StringBuilder stringBuilder = new StringBuilder(data.length * SECOND_BITMASK); int length = data.length; for (int i = EventIDNotificationAdded; i < length; i += FIRST_BITMASK) { Object[] objArr = new Object[FIRST_BITMASK]; objArr[EventIDNotificationAdded] = Byte.valueOf(data[i]); stringBuilder.append(String.format("%02X", objArr)); } return stringBuilder.toString(); } }