About Question enthuware.ocpjp.v7.2.1714 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

About Question enthuware.ocpjp.v7.2.1714 :

Post by The_Nick »

Regarding DataInput and DataOutput implementations, why should I use writeChars over writeUTF? What's the difference between the two?

Thanks in advance.

The_Nick.

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1714 :

Post by admin »

The difference is given in the API description itself:

writeChars: Writes every character in the string s, to the output stream, in order, two bytes per character.

writeUTF: Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in the string s.

So if you want what you've written to be read on machines with a different default character encoding, you should write Strings using UTF.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 268 guests