This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Files" Watch "Files" New topic


josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
FileOutputStream o = new FileOutputStream
String s = "test"
for(int i =0 i<s.length();i++)>
outStream.write(s.charAt(i)); //4bytes are written
It is given in mock exam that the above outStream obj
writes 4 bytes ? how is this ?
I think it is 8 bytes becoz u have a characters which are
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
the .write(..) method writes ONLY the LOWER BYTE of the argument.
maha anna
asim manzar

Joined: Feb 14, 2001
Posts: 1
Can you please elaborate on your answer a little bit? I also thought that 8 bytes should be written for each character.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Your name 'shan' does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Files
It's not a secret anymore!