Java - Write code to convert byte array to Hex String using shift right operator

Requirements

Write code to convert byte array to Hex String using shift right operator

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        byte[] b = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(toHexString(b));
    }// www . ja  v a 2 s .c  om

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

    public static String toHexString(byte[] b) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            sb.append(hexCharsLowerCase[(int) (((int) b[i] >> 4) & 0x0f)]);
            sb.append(hexCharsLowerCase[(int) (((int) b[i]) & 0x0f)]);
        }
        return sb.toString();
    }
}