Here you can find the source of FormatAs2CharHexa(byte byValue)
static public String FormatAs2CharHexa(byte byValue)
//package com.java2s; /*//from w w w.ja va 2 s . co m * JLib - Publicitas Java library v1.2.0. * * Copyright (c) 2005, 2006, 2007, 2008, 2009 Publicitas SA. * Licensed under LGPL (LGPL-LICENSE.txt) license. */ public class Main { static public String FormatAs2CharHexa(int nValue) { String cs = ""; char c; for (int n = 0; n < 2; n++) { int nChar = nValue % 16; nValue = nValue / 16; if (nChar <= 9) c = (char) ('0' + nChar); else c = (char) ('A' + nChar - 10); cs = c + cs; } return cs; } static public String FormatAs2CharHexa(byte byValue) { if (byValue < 0) return FormatAs2CharHexa((int) byValue + 256); else return FormatAs2CharHexa((int) byValue); } }