![]() |
#2
rohalloway2020-03-30 22:43
|

try {
DataInputStream dis = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
boolean offon = true;
do
{
String reviMsg = dis.readUTF();
System.out.println("从客户端" + clientNo + "接收到的数据为:" + reviMsg);
if(reviMsg == "end") {
System.out.println("offon = false;");
offon = false;
}
}
while (offset);
}
请问,当我在客户端发送 end 时,为什么不能结束循环呢?
打印的reviMsg 明明就是end,谢谢!
我想实现:当检测到客户端发来的数据为end时停止循环