Here you can find the source of byteToHex(final byte b)
private static String byteToHex(final byte b)
//package com.java2s; /*//from www.j a v a 2 s. c o m * Copyright Nathan Jones 2013 * * This file is part of Juzidian. * * Juzidian is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Juzidian is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Juzidian. If not, see <http://www.gnu.org/licenses/>. */ public class Main { private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; private static String byteToHex(final byte b) { final char byteHexChar1 = HEX_CHARS[(b & 0xf0) >> 4]; final char byteHexChar2 = HEX_CHARS[b & 0x0f]; return byteHexChar1 + "" + byteHexChar2; } }