Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static int parseHex(byte b) { if (b >= '0' && b <= '9') return (b - '0'); if (b >= 'A' && b <= 'F') return (b - 'A' + 10); if (b >= 'a' && b <= 'f') return (b - 'a' + 10); throw new IllegalArgumentException("Invalid hex char '" + b + "'"); } }