tagId is set to an array of bytes. You need to parse that array to a hex string. There's lots of ways to do that, but this code will do it without resorting to external .