I am working on a project where efficiency is key, and need to write unsigned ints over the network. My code is like this:
DataOutputStream out = ...;
int value = ...;
out.writeUnsignedInt(value);
For reading:
DataInputStream in = ...;
int value = in.readUnsignedInt();
So to be clear: I want to write 4 bytes, and my value is not larger than 2^31-1
(that's why my input/output variables are ints. The values are larger than 2^15-1
however)
I am using Java 8 if it matters. Thank you for your time, and sorry in advance if I've done something stupid