Java Byte to String byteToString(int n)

Here you can find the source of byteToString(int n)

Description

Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of n.

License

Open Source License

Declaration

public static String byteToString(int n) 

Method Source Code

//package com.java2s;
// the terms and conditions of the Cryptix General Licence. You should have

public class Main {
    private static final char[] hexDigits = { '0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    /**//from  w w  w  .j  a v a  2s  . c om
     * Returns a string of 2 hexadecimal digits (most significant digit first)
     * corresponding to the lowest 8 bits of <i>n</i>.
     */
    public static String byteToString(int n) {
        char[] buf = { hexDigits[(n >>> 4) & 0x0F], hexDigits[n & 0x0F] };
        return new String(buf);
    }
}

Related

  1. byteToString(byte b_)
  2. byteToString(int b)
  3. ByteToString(int b)
  4. byteToString(int b)
  5. byteToString(int b)
  6. byteToString(int n)
  7. byteToString(int val)