---
title: "What is difference between PrintWriter and ServletOutputStream?"  
description: "What is difference between PrintWriter and ServletOutputStream?"  
author: "Anonymous User"  
published: 2014-11-03  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/2240/what-is-difference-between-printwriter-and-servletoutputstream  
category: "java"  
tags: ["oops"]  
reading_time: 1 minute  

---

# 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.

## Answers

### Answer by Anonymous User

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.


---

Original Source: https://www.mindstick.com/interview/2240/what-is-difference-between-printwriter-and-servletoutputstream

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
