Java - Write code to convert byte To Hex Char

Requirements

Write code to convert byte To Hex Char

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        byte b = 42;
        System.out.println(java.util.Arrays.toString(byteToHexChar(b)));
    }/* ww w. jav  a 2s. com*/

    public static char[] byteToHexChar(byte b) {
        char[] ch = new char[2];
        if (b > 0xFF) {
            return null;
        }

        ch[0] = "0123456789ABCDEF".charAt((b & 0xF0) >> 4);
        ch[1] = "0123456789ABCDEF".charAt((b & 0x0F));
        return ch;
    }
}