×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Let me try

java.io.Writer is at a "higher" level than java.io.OutputStream. Outputstream writes bytes, while Writer write characters.
All the tasks that Writer can take care can also be handled OutputStream.

However, if you are not outputing the characters, you probably are forced to use Outputstream. For instance, if you want your servlet to output an image, you have to use response.getServletOutput(). On the other hand, if you are just creating some HTML pages, you use either the former or response.getWriter().

Hope it helps.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请问java中,write 和 OutputStream 的区别和联系,谢谢
    • Let me try
      java.io.Writer is at a "higher" level than java.io.OutputStream. Outputstream writes bytes, while Writer write characters.
      All the tasks that Writer can take care can also be handled OutputStream.

      However, if you are not outputing the characters, you probably are forced to use Outputstream. For instance, if you want your servlet to output an image, you have to use response.getServletOutput(). On the other hand, if you are just creating some HTML pages, you use either the former or response.getWriter().

      Hope it helps.
      • thanks.