Here you can find the source of byteToHexChars(int n)
public static char[] byteToHexChars(int n)
//package com.java2s; /**/*from w w w . j a v a 2s . co m*/ * Copyright 2001-2014 CryptoHeaven Corp. All Rights Reserved. * * This software is the confidential and proprietary information * of CryptoHeaven Corp. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with CryptoHeaven Corp. */ public class Main { /** data for hexadecimal visualisation. */ private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Returns an array of 2 hexadecimal digits (most significant * digit first) corresponding to the lowest 8 bits of <i>n</i>. */ public static char[] byteToHexChars(int n) { char[] buf = { HEX_DIGITS[(n >>> 4) & 0x0F], HEX_DIGITS[n & 0x0F] }; return buf; } }