Java - Write code to convert single byte To Hex String

Requirements

Write code to byte To Hex String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        byte argByte = 142;
        System.out.println(byteToHexString(argByte));
    }/*from   w ww  . j a v  a 2  s.co m*/

    public static String byteToHexString(final byte argByte) {
        int wrkValue = argByte;
        if (wrkValue < 0) {
            wrkValue += 0x100;
        }
        String result = Integer.toHexString(wrkValue);
        if (result.length() < 2) {
            result = "0" + result;
        }
        return result;
    }
}