Java Byte to Hex String byteToHexString(byte _b)

Here you can find the source of byteToHexString(byte _b)

Description

byte To Hex String

License

Open Source License

Declaration

public static String byteToHexString(byte _b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    public static String byteToHexString(byte _b) {
        if ((_b < 0) || (_b > 0xf)) {
            return Integer.toHexString(_b & 0xFF);
        } else {//from w  ww.j a  va2  s.co m
            StringBuffer sb = new StringBuffer();
            sb.append('0');
            sb.append(hexChars[_b]);
            return sb.toString();
        }
    }
}

Related

  1. byteToHexStr(byte b)
  2. byteToHexStr(byte buf[])
  3. byteToHexStr(byte src, int len, int code)
  4. byteToHexstr(byte[] b, boolean space)
  5. byteToHexStr(byte[] bArray)
  6. byteToHexString(byte b)
  7. byteToHexString(byte b)
  8. byteToHexString(byte b)
  9. byteToHexString(byte b)