From 3859e991f48e1ef6a52ba23b8bc30130015756e7 Mon Sep 17 00:00:00 2001 From: Zeyong Shan Date: Fri, 21 Jul 2017 18:18:03 -0700 Subject: [PATCH] fix the issue that one more empty character in the end (running on the jre 1.8x) --- .../GameServer/src/ClientThread.java" | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git "a/ODSocket_Demo1/\346\234\215\345\212\241\347\253\257/GameServer/src/ClientThread.java" "b/ODSocket_Demo1/\346\234\215\345\212\241\347\253\257/GameServer/src/ClientThread.java" index 035bb26..9944f6a 100644 --- "a/ODSocket_Demo1/\346\234\215\345\212\241\347\253\257/GameServer/src/ClientThread.java" +++ "b/ODSocket_Demo1/\346\234\215\345\212\241\347\253\257/GameServer/src/ClientThread.java" @@ -32,7 +32,9 @@ public void run() { for (Socket socket : clients) { // 获取客户端发来的数据 InputStream is = socket.getInputStream(); - int len = is.available() + 1; + //int len = is.available() + 1; + int len = is.available(); + //jre 1.8 环境下结尾会多出一位空白字符。 byte[] buff = new byte[len]; int flag = is.read(buff);