An octet (aka: byte) is the unit of data transfer on ther internet and most other network techonoliges. It's your job to convert between your data and a series of bytes.
Being that I like NIO I'd do something like:
1 2 3 4
| byte[] data = ...; java.nio.ByteBuffer bb = ByteBuffer.wrap(data); int x = bb.getInt(); int y = bb.getInt(); |
Another way would be to wrap the data array in a java.io.ByteArrayInputStream and wrap that in a java.io.DataInputStream and then use the readInt() method.
I think but have no real proof that the NIO method is more efficient but without testing I don't know.