WHAT IS DIFFERENCE BETWEEN PRINTWRITER AND SERVLETOUTPUTSTREAM?

Kamlakar Singh

Total Post:80

Points:400
Posted by  Kamlakar Singh
OOPS 
 2035  View(s)
Ratings:
Rate this:
  1. Kamlakar Singh

    Post:80

    Points:400
    What is difference between PrintWriter and ServletOutputStream?

    PrintWriter is a character-stream class whereas ServletOutputStream is a byte-stream class. We can use PrintWriter to write character based information such as character array and String to the response whereas we can use ServletOutputStream to write byte array data to the response.

    We can use ServletResponse getWriter() to get the PrintWriter instance whereas we can use ServletResponse getOutputStream() method to get the ServletOutputStream object reference.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!