我有一个基于套接字的服务器-客户端通信通道。我将 3 个整数值打包到 byte[] 并将其写入套接字 OutputStream,但我如何将其转换回来?
代码简单:
ByteBuffer b = ByteBuffer.allocate(12);
b.putInt(BTActions.READY_FOR_GAME);
b.putInt(i);
b.putInt(l);
try
{
mAcceptThread.getWriteSocket().write(b.array());
}
catch (IOException e)
{
e.printStackTrace();
}