- while (true) {
- byte[] recbuff = new byte[1024];
- ss.receive(new DatagramPacket(recbuff,1024));
-
- System.out.println(new String(recbuff.toString()).equals("over"));
- if (new String(recbuff).equals("over")) {
- System.out.println("being close");
- ss.close();
- return;}
-
- System.out.println("服务器端--客户端输入的内容为:" + new String(recbuff));}
复制代码 以上代码中当客户端输入“over”时,可以打印出“over”,但if语句中的equals返回的却是false,求大神们帮忙解释下是怎么回事,如果我用byte[] buff="over".getBytes();new String(buff).equals("over")就能比较出正确的结果
|