aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is charS? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is charS?" Watch "What is charS?" New topic

What is charS?

Tom Baker

Joined: Oct 17, 2000
Posts: 6
On a mock exam I had a question dealing with "charS" does anyone have an idea what it is reference to. (the mock exam answer was vague, but said it had to do with inputstreamreader?)
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
The DataOutputStream has a method writeChars(String s) which will write the String s, writing one char at a time. Since this is part of the OutputStream class it writes it in bytes so you get two bytes per char and once the entire string is written the counter written is incremented by twice the length of the string.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347

perhaps you can help me. Why would I want to write a String using a DataOutputStream? I would think that I would always use a Writer of some sort, wrapped in a BufferedWriter and probably that wrapped in a PrintWriter.

Visit my download page
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Randall, I wouldn't use DataOutputStream. That is what Readers and Writers are for. But the functionality is provided in DataOutputStream.
subject: What is charS?