ITeye博客

Response的OutputStream和Writer

wiki_more · 2012-04-11 10:48 · JAVA基础 · 编程语言 · Markdown

public ServletOutputStream getOutputStream() throws IOException {
  if (this.servletOutputStream == null) {
     this.servletOutputStream = new ServletOutputStreamAdapter(this.exchange.getResponseBody());
   }
    return this.servletOutputStream;
  }
  public PrintWriter getWriter() throws IOException {
    if (this.writer == null) {
      if (this.characterEncoding != null) {
        this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(this.exchange.getResponseBody(), this.characterEncoding)));
       }
     else {
       this.writer = new PrintWriter(this.exchange.getResponseBody());
       }
   }
    return this.writer;
}

 所以用完以后要关闭

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。