I am converting an arbitrary ascii string, which is incidently a number padded with zeros, for example "1" as "0000000001" then to bytes then back in python. Of course the value can be "0000004231" etc. also. It is always numeric and within range of signed 32bit value padded by zeros.
When I tell python that it is bytes and I want it in int, it converts it to a nice large random looking number. Then I can convert it back to original value later using to_bytes()
function.
In [74]: value = int.from_bytes(bytes(format(1, '010d'),'ascii'), byteorder='little')
In [75]: value.to_bytes(10,byteorder=sys.byteorder)
Out[75]: b'0000000001'
In [76]: value
Out[76]: 232284873704446901628976
In [77]:
How can I achieve same with java?
Exact(?) functional replica of your code in Java:
And back:
In any case, if you make the python code use big-endian, you can skip the array reversals in Java.