// convert a single byte b to a 2-char hex string // with possible leading zero. String s2 = Integer.toString( ( b & 0xff ) + 0x100, 16 /* radix */ ).substring( 1 );