Here you can find the source of toHexChar(int digit)
private static char toHexChar(int digit)
//package com.java2s; /*//ww w . j ava 2s .c o m * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ public class Main { /** '0' - '9', 'A', 'B', 'C', 'D', 'E', 'F' */ private static char toHexChar(int digit) { digit &= 0x0F; // last four bits if (digit < 10) { return (char) ('0' + digit); } return (char) (('A' - 10) + digit); } }