Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between writeUTF and writeChars?

What's the difference between writeUTF and writeChars? (methods of ObjectOutputStream) Further I have not found the corresponding readChars in ObjectInputStream.

like image 559
Indeed ItIs Avatar asked Sep 22 '13 15:09

Indeed ItIs


1 Answers

writeUTF writes text in UTF-8 format encoding preceeded with text length, so readUTF knows how many characters to read from stream.

writeChars writes text as a sequence of 2-bytes chars with no length. To read it, we should use readChar method and we need to know how many chars were written.

like image 83
Evgeniy Dorofeev Avatar answered Oct 13 '22 15:10

Evgeniy Dorofeev