我试图让一个非常简单的Client-Server
系统工作,其中Client
将发送一个字符串到Server
,server
然后将该字符串存储到一个文件中。
客户端通过以下方式发送字符串:
//Other Code
sockStrm = new DataOutputStream (clientSocket.getOutputStream ());
//Other code
sockStrm.writeChars (line);
//Other code
服务器接收字符串:
//Other code
strm = new BufferedReader (new InputStreamReader (clientSocket.getInputStream ()));
//Other code
stringLine = strm.readLine ();
//Other code
当我发送字符串STOP
时,客户端的字符串长度为 4,服务器端的字符串长度为 9,并显示为STOP
我试图在服务器端对收到的字符串进行子串化,但没有运气。
有关如何处理此问题的任何指示?