File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes PrintWriter  vs OutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "PrintWriter  vs OutputStream" Watch "PrintWriter  vs OutputStream" New topic

PrintWriter vs OutputStream

samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
can anybody help me
what is the difference between PrintWriter and OutputStream
which should we use . which is better?
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
PrintWriter is only for character data and OutputStream for everything (binary data, character data).

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Alexandre Cervieri

Joined: Aug 02, 2005
Posts: 27
In addition, you cannot use both PrintWriter and OutputStream. If you obtained one of them and try to get the other you will get a IllegalStateException. See also the following thread:
I agree. Here's the link:
subject: PrintWriter vs OutputStream
jQuery in Action, 3rd edition