Create byte[] in Jython

Viewed 5792

I am developing with Jython and I need to use a Java method that requires a byte[] as a parameter.

I tried:

def randomBytesArray(length):
    data = []
    for _ in xrange(length):
        data.append(chr(random.getrandbits(8)))
    methodThatNeedsBytesArrays(data)

But I get this error:

TypeError: methodThatNeedsBytesArrays(): 1st arg can't be coerced to byte[]
1 Answers
Related