What is difference between PrintWriter and ServletOutputStream?

Total Post:80

Points:400

OOPS 
 5064  View(s)
Ratings:
Rate this:
  1. 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