File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "PrintWriter  vs OutputStream" Watch "PrintWriter  vs OutputStream" New topic
Author

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
Greenhorn

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:
http://www.coderanch.com/t/170147/java-Web-Component-SCWCD/certification/servlet-getWriter-output-stream
 
Consider Paul's rocket mass heater.
 
subject: PrintWriter vs OutputStream
 
Similar Threads
Difference between PrintWriter and Output Stream.
why should we set response.setContentType before using PrintWriter or OutputStream?
problem with PrintWriter
what is the difference between printStream and PrintWriter?
PrintStream & PrintWriter