As others have noted, the BigInteger constructor should be fine. It is worth noting that the JVM is a big endiator, so just make sure that the byte array you are passing in is as well. You do not need to do anything if you get bytes from the socket, since the network byte order is also large, but this can be a problem if you are running on a small end computer such as x86 and receiving data through some other means.
source share