private static void byte2hex ( byte b , StringBuffer buf ) { char [ ] hexChars = { ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' } ; int high = ( ( b & 0xf0 ) >> 4 ) ; int low = ( b & 0x0f ) ; buf . append ( hexChars [ high ] ) ; buf . append ( hexChars [ low ] ) ; }
Converts a byte to hex digit and writes to the supplied buffer