Here you can find the source of charToNum(char c)
private static byte charToNum(char c)
//package com.java2s; //License from project: Open Source License public class Main { private static byte charToNum(char c) { switch (c) { case '0': return 0x0; case '1': return 0x1; case '2': return 0x2; case '3': return 0x3; case '4': return 0x4; case '5': return 0x5; case '6': return 0x6; case '7': return 0x7; case '8': return 0x8; case '9': return 0x9; case 'a': case 'A': return 0xA; case 'b': case 'B': return 0xB; case 'c': case 'C': return 0xC; case 'd': case 'D': return 0xD; case 'e': case 'E': return 0xE; case 'f': case 'F': return 0xF; default:/*from w ww . jav a 2 s. co m*/ throw new NumberFormatException(String.format("%c is not a valid hex digit", c)); } } }