There is a significant difference between writing a String into the stream as primitive data or as an Object. A String instance written by writeObject is written into the stream as a String initially. Future writeObject() calls write references to the string into the stream.
For Example
ByteArrayOutputStream baos1=new ByteArrayOutputStream();
oos1=new ObjectOutputStream(baos1);
baos2=new ByteArrayOutputStream();
ObjectOutputStream oos2=new ObjectOutputStream(baos2);
String testString="First";
oos1.writeObject(testString);
oos2.writeUTF(testString);
testString="Second";
oos1.writeObject(testString);
oos2.writeUTF(testString);
testString="Third";
oos1.writeObject(testString);
oos2.writeUTF(testString);
oos1.flush();
oos2.flush();
byte[] byteArray1=baos1.toByteArray();
byte[] byteArray2=baos2.toByteArray();
Dump last two arrays you will get result like:
writeObject i.e. byteArray1
Binary: -84 -19 0 5 116 0 5 70 105 114 115 116 116 0 6 83 101 99 111 110 100 116 0 5 84 104 105 114 100
ASCII: -T - t F i r s t t S e c o n d t T h i r d
writeUTF i.e. byteArray2
Binary: -84 -19 0 5 119 22 0 5 70 105 114 115 116 0 6 83 101 99 111 110 100 0 5 84 104 105 114 100
ASCII: -T - w F i r s t S e c o n d T h i r d
Conclusion: In case of writeObject an extra data (here t)to be streamed whereas in case of writeUTF only the string data to be streamed.
For more: http://docs.oracle.com/javase/7/docs/api/java/io/ObjectOutputStream.html#writeUTF(java.lang.String)