I tried to convert
byte bytes = new bytes;
ByteBuffer buff = ByteBuffer.allocate(4);
You forgot to
flip() your buffer after putting data in.
After you've put the
int in the buffer, the position is at the end of the buffer. Trying to read data results in
BufferUnderflowException (not overflow) since there are no bytes left to read in the buffer.