我有这个代码通过套接字发送一个字节数组:
byte[] code_b = code.getBytes("US-ASCII");
byte[] id_b = id.getBytes("US-ASCII");
byte[] username_b = username.getBytes("US-ASCII");
ByteBuffer chapAsk = ByteBuffer.allocate(lengthmsg);
chapAsk.put(code_b);
chapAsk.put(id_b);
chapAsk.putShort((short)(lengthmsg));
chapAsk.put(username_b);
chapAsk.array(); //several bytes together - concat
sal.println(chapAsk); //with this I send the array through the socket
有了这个我发送数组但现在我想在Socket服务器上接收数组并将字节保存在一个新数组中。我怎么能这样做?