Do I need to flush the servlet outputstream?

后端 未结 4 478
闹比i
闹比i 2020-12-08 09:57

Do I need to \"flush\" the OutputStream from the HttpServletResponse?

I already saw from to Should I close the servlet outputstream? that I don\'t need to close it,

4条回答
  •  青春惊慌失措
    2020-12-08 10:35

    java.lang.Object
      extended byjava.io.Writer
          extended byjavax.servlet.jsp.JspWriter
    
    
    close
    public abstract void close()
                        throws IOException
    Close the stream, flushing it first. 
    This method needs not be invoked explicitly for the initial JspWriter as the code generated by the JSP container will automatically include a call to close(). 
    
    Closing a previously-closed stream, unlike flush(), has no effect. 
    
    
    Throws: 
    IOException - If an I/O error occurs
    
    ============================
    
    So, DO NOT close the output stream explicitly.
    

提交回复
热议问题