0

I have this client code

dOut = new DataOutputStream(socket.getOutputStream());
oos = new ObjectOutputStream(socket.getOutputStream());
dOut.writeByte(2);  <--when readByte on server gives -84
oos.writeObject(rectangle);

if slightly changed

dOut = new DataOutputStream(socket.getOutputStream());
dOut.writeByte(2);  <--when readByte on server gives 2
oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(rectangle);

why is this happening? case is similar in inputstream as well.

1 Answer 1

1

Yes. The data will get hopelessly mixed up.

There's no need for this. ObjectOutputStream already has all the methods of DataOutputStream. You don't need them both.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.