當在Java中增加一些內容,HttpServletResponse的我可以得到響應作家和追加:HttpServletResponse的 - 寫響應作家VS的OutputStream
httpResponse.getWriter().append("Some Content");
或者,我可以給OutputStream中添加內容:
ServletOutputStream servletOut = httpResponse.getOutputStream();
servletOut.write(someByteArray);
兩者之間的唯一區別是第一個獲取字符串/字符序列,第二個獲取字節(當然內容類型也受到影響)?我應該更喜歡一個嗎?我應該什麼時候使用哪個?
請看http://stackoverflow.com/questions/6883715/whats-the-difference-between-printwriter-and-outputstream –