Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PrintWriter and OutputStream

 
parra matta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On page 132 in HFJS, it says that for ServletOutputStream use write() and for PrintWriter use println().

However ServletOutputStream has lots of method print or println and PrintWriter has lots of methd write. and Acutally I can use println for ServletOutputStream and write for PrintWriter.

Is the book wrong?
 
Akshay Kiran
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use any method you want,
but to make the most out of efficiency,
use the write method of ServletOutputStream
and print, println of PrintWriter
(because PrintWriter is specially made for character and text based output while the regular outputstream is used for writing out other forms of data like binary etc.)
which is exactly what the book recommends you to do
 
parra matta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Akshay.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic