Android Byte to Hex Convert toHexString(byte byt)

Here you can find the source of toHexString(byte byt)

Description

to Hex String

Declaration

private static String toHexString(byte byt) 

Method Source Code

//package com.java2s;

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

    private static String toHexString(byte[] data, int offset, int length) {
        StringBuilder s = new StringBuilder(length * 2);
        int end = offset + length;

        int high_nibble;
        int low_nibble;

        for (int i = offset; i < end; i++) {
            high_nibble = (data[i] & 0xF0) >>> 4;
            low_nibble = (data[i] & 0x0F);

            s.append(HEXS[high_nibble]);
            s.append(HEXS[low_nibble]);/* www. j a  v  a  2  s . c om*/
        }

        return s.toString();
    }

    private static String toHexString(byte byt) {
        String result = null;

        int high_nibble;
        int low_nibble;

        high_nibble = (byt & 0xF0) >>> 4;
        low_nibble = (byt & 0x0F);

        result = "" + HEXS[high_nibble] + HEXS[low_nibble];

        return result;
    }
}

Related

  1. appendHex(StringBuffer sb, byte b)
  2. toHexString(byte abyte0)
  3. byteToHexString(byte b)
  4. getHexString(byte i)
  5. toHexString(byte b)
  6. getBinaryStrFromByte(byte b)
  7. getBinaryString(byte src)
  8. byteToHex(byte b)
  9. byteToHex(byte data)