File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 agree. Here's the link:
subject: Files
It's not a secret anymore!