Here you can find the source of char2Hex(char c)
static public String char2Hex(char c)
//package com.java2s; //License from project: Open Source License public class Main { static public String char2Hex(char c) { // Returns hex String representation of char c byte hi = (byte) (c >>> 8); byte lo = (byte) (c & 0xff); return byte2Hex(hi) + byte2Hex(lo); }//from ww w . j av a2 s. c o m static public String byte2Hex(byte b) { // Returns hex String representation of byte b final char hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] }; return new String(array); } }