且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java 客户端/服务器 - 通过 Socket 连接发送多个字符串

更新时间:2023-11-07 19:26:58

您的读取循环不正确.它们应该是一般形式:

Your read loops are incorrect. They should be of the general form:

String line;
while ((line = reader.readLine()) != null) {
    // Do something with `line`
}

目前你正在扔掉每一个奇数行,如果有奇数行,则打印一个空值.

At present you are throwing away every odd line, and printing a null if there is an odd number of lines.