views:

78

answers:

1

I'm building a system to exchange encoded messages, call it bank and client. The first messages that I need to exchange are long Strings. They appear to be truncated either in the write or read, but I'm not sure how to figure out where.

Read:

client = new Socket(InetAddress.getByName(bankServer), 12345);
displayMessage("Connected to: " + client.getInetAddress().getHostName());
input = new ObjectInputStream(client.getInputStream());
inputString = (String) input.readObject();

Write:

 output = new ObjectOutputStream(connection.getOutputStream());
 output.flush(); // flush output buffer to send header information
 output.writeObject(msgClassOut + msgTypeOut.toString() + key);
 output.flush();
A: 

I think I figured it out. The "key" data was initially being sent as byte[]. I changed it to String and it's all getting transferred, no truncation.

Deb