• 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

Differece between PrintWriter and OutputStream

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I want to write some arbitrary binary data, can I use PrintWriter instead of OutputStream? I see the PrintWriter does have the write() method although it doesn't have one taking byte/byte[] arguments. If I want to write some binary data, can I just write it using write(int c)?

In short what are the difference between PrintWriter and OutputSteam?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Writer and Reader classes deal with textual characters (type char) and do some translation between Unicode and the real platform's file encoding. Stream classes deal in binary data (type byte), and do no such translation. So the answer is no, if you want to write binary data, don't use any Writer class; use an OutputStream of some kind.

Here is a nice tutorial which teaches you all about these classes, their relationships, and their uses.
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic