Here you can find the source of byteToHexString(byte src)
public static String byteToHexString(byte src)
//package com.java2s; //License from project: Apache License public class Main { public static String byteToHexString(byte src) { StringBuilder stringBuilder = new StringBuilder(""); int v = src & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0);/*w w w . j a va 2 s .c o m*/ } stringBuilder.append(hv); return stringBuilder.toString(); } public static String toHexString(String s) { byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { try { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } catch (Exception e) { e.printStackTrace(); } } try { s = new String(baKeyword, "utf-8");// UTF-16le:Not } catch (Exception e1) { e1.printStackTrace(); } return s; } }