This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Similar Threads
problem with PrintWriter
PrintStream & PrintWriter
why should we set response.setContentType before using PrintWriter or OutputStream?
what is the difference between printStream and PrintWriter?
Difference between PrintWriter and Output Stream.