Here you can find the source of byteToHex(int v)
Parameter | Description |
---|---|
v | integer with a byte value (-128 .. 255); other values get truncated |
public static String byteToHex(int v)
//package com.java2s; //License from project: Open Source License public class Main { /** Returns a two char hexadecimal String representation of a single byte. * /*from w w w . j a va 2 s.com*/ * @param v integer with a byte value (-128 .. 255); other values get truncated * @return an absolute hex value representation (unsigned) of the input */ public static String byteToHex(int v) { String hstr; hstr = Integer.toString(v & 0xff, 16); return hstr.length() == 1 ? "0" + hstr : hstr; } }