Here you can find the source of encode(byte[] rawData)
public static String encode(byte[] rawData)
//package com.java2s; //License from project: LGPL import java.io.UnsupportedEncodingException; public class Main { private static String charset = "ISO-8859-1"; public static String encode(String sourceText) throws UnsupportedEncodingException { return encode(sourceText.getBytes(getCharset())); }/*from ww w . j av a 2 s . c o m*/ public static String encode(byte[] rawData) { StringBuilder hexText = new StringBuilder(); String initialHex = null; int initHexLength = 0; for (int i = 0; i < rawData.length; i++) { int positiveValue = rawData[i] & 0x000000FF; initialHex = Integer.toHexString(positiveValue); initHexLength = initialHex.length(); while (initHexLength++ < 2) { hexText.append("0"); } hexText.append(initialHex); } return hexText.toString(); } public static String encode(byte rawData) { StringBuilder hexText = new StringBuilder(); String initialHex = null; int initHexLength = 0; int positiveValue = rawData & 0x000000FF; initialHex = Integer.toHexString(positiveValue); initHexLength = initialHex.length(); while (initHexLength++ < 2) { hexText.append("0"); } hexText.append(initialHex); return hexText.toString(); } public static String getCharset() { return charset; } }