Java Byte to Hex Char byteToHexChar(byte b)

Here you can find the source of byteToHexChar(byte b)

Description

byte To Hex Char

License

Apache License

Declaration

private static Object byteToHexChar(byte b) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

    private static Object byteToHexChar(byte b) {
        int n = b;
        if (n < 0) {
            n = 256 + n;//from  w w w.ja va 2  s  . c o m
        }
        int d1 = n / 16;
        int d2 = n % 16;
        return hex[d1] + hex[d2];
    }
}

Related

  1. byteToHexChars(byte value)
  2. byteToHexChars(int n)