• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Files

 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the .write(..) method writes ONLY the LOWER BYTE of the argument.
maha anna
 
asim manzar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your name 'shan' does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.
Ajith
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic