• 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

PrintWriter and OutputStream

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Akshay.
reply
    Bookmark Topic Watch Topic
  • New Topic