wood burning stoves*
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
Author

Files

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
outStream.close()
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
written
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
Greenhorn

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

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

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Files
 
Similar Threads
FileOutputStream flush position of channel
wierd effects with File Channel write
I/O Clarification
Mock exam question
Gets the output of the ObjectOutputStream in a program