Class DelegatingServletOutputStream

java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.springframework.mock.web.DelegatingServletOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class DelegatingServletOutputStream extends jakarta.servlet.ServletOutputStream
Delegating implementation of ServletOutputStream.

Used by MockHttpServletResponse; typically not directly used for testing application controllers.

Since:
1.0.2
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • DelegatingServletOutputStream

      public DelegatingServletOutputStream(OutputStream targetStream)
      Create a DelegatingServletOutputStream for the given target stream.
      Parameters:
      targetStream - the target stream (never null)
  • Method Details

    • getTargetStream

      public final OutputStream getTargetStream()
      Return the underlying target stream (never null).
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class jakarta.servlet.ServletOutputStream
      Throws:
      IOException
    • isReady

      public boolean isReady()
      Specified by:
      isReady in class jakarta.servlet.ServletOutputStream
    • setWriteListener

      public void setWriteListener(jakarta.servlet.WriteListener writeListener)
      Specified by:
      setWriteListener in class jakarta.servlet.ServletOutputStream