0

I am porting some Python code to Java, well, a lot is done but I got stuck on this function. It should convert an int to a byte[] array.

I know that the if-statement is like ? :, but I need some help.

def adjustId(self, _id):
        _id = format(_id, 'x')
        zfiller = len(_id) if len(_id) % 2 == 0 else len(_id) + 1
        _id = _id.zfill(zfiller if zfiller > 6 else 6)
        # if len(_id) % 2:
        #     _id = "0" + _id
        return binascii.unhexlify(_id)

So my question: How do I convert this code into java?

gi097
  • 7,313
  • 3
  • 27
  • 49

1 Answers1

0

You must use Python module "struct" pack unpack for convert int->bytes Then convert Python "bytes" type to a tuple of bytes