Here you can find the source of byteToString(int n)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of n
.
Parameter | Description |
---|---|
n | the byte value to convert. |
public static String byteToString(int n)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray(); /**//from w w w .j a va 2 s. co m * <p>Returns a string of 2 hexadecimal digits (most significant digit first) * corresponding to the lowest 8 bits of <code>n</code>.</p> * * @param n the byte value to convert. * @return a string of 2 hex characters representing the input. */ public static String byteToString(int n) { char[] buf = { HEX_DIGITS[(n >>> 4) & 0x0F], HEX_DIGITS[n & 0x0F] }; return new String(buf); } }