我正在构建一个系统来交换编码消息,称之为银行和客户端。我需要交换的第一条消息是长字符串。它们似乎在写入或读取时被截断,但我不确定如何找出在哪里。
读:
client = new Socket(InetAddress.getByName(bankServer), 12345);
displayMessage("Connected to: " + client.getInetAddress().getHostName());
input = new ObjectInputStream(client.getInputStream());
inputString = (String) input.readObject();
写:
output = new ObjectOutputStream(connection.getOutputStream());
output.flush(); // flush output buffer to send header information
output.writeObject(msgClassOut + msgTypeOut.toString() + key);
output.flush();