The same method (writeInt()) in ObjectOutputStream and DataOutputStream writes different data? Isn't it supposed to be equal for primitive types?
// Output: 14 bytes file
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("file_14bytes.bin"));
out.writeInt(1);
out.writeInt(2);
out.close();
// Output: 8 bytes file
DataOutputStream dout= new DataOutputStream(new FileOutputStream("file_8bytes.bin"));
dout.writeInt(3);
dout.writeInt(4);
dout.close();
For example, I wanted to send objects info on first connection using objectoutputstream's writeObject() method, and then send x, y floats in loop with OOS's writeInt().