• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I/O

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if filewriter character based streams write 'characters'to the stream then who converts them to binary code while saving in file??
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have also been confused about this question. Here is my take on this.
A FileWriter takes the textual representation of characters from from a PrintWriter (to which it is chained) and writes the binary representation of file. I think by saying 'FileWriter' writes characters, means that it can take a 'character stream', such as that provided by a PrintWriter, as an input however the output will be a binary file.
Again, if someone can clarify.
zulfiqar raza
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My try!
FileWriter is a subclass of OutputStreamWriter.
I think the FileWriter can write text and characters to a file with no problem. But when reading it has to tokenize the characters.errr am i correct?
Ref: A common strategy used to read textual representation, is to write lines of text is tokenize the characters as they are read, line at a time.Khalid book pg574
 
faiza haris
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another Try
http://java.sun.com/products/jdk/1.2/docs/api/java/io/OutputStreamWriter.html
Since FileWriter is subclass of OutputStreamWriter so it also inherits the CharToByte Convertor.
Hope thats your answer.
 
zulfiqar raza
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, an OutputStreamWriter is always chained to an underlying FileOutputStream. It is this FileOutputStream that writes binary files, while the OutputStreamWriter has the notion of character encoding and takes Character Streams...
So in the end a binary file is written through a FileOutputStream OR using a FileWriter, which does not need an underlying FileOutputStream. However using a FileWriter is equivalent to an OutputStreamWriter chained to an underlying FileOutputStream.
zulfiqar raza
[This message has been edited by zulfiqar raza (edited November 24, 2000).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic