📜  如何在套接字 java 代码示例中发送字节数组

📅  最后修改于: 2022-03-11 14:52:07.493000             🧑  作者: Mango

代码示例2
Socket socket = ...
DataInputStream dIn = new DataInputStream(socket.getInputStream());

int length = dIn.readInt();                    // read length of incoming message
if(length>0) {
    byte[] message = new byte[length];
    dIn.readFully(message, 0, message.length); // read the message
}