Class UndertowOutputStream

  • All Implemented Interfaces:
    BufferWritableOutputStream, java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class UndertowOutputStream
    extends java.io.OutputStream
    implements BufferWritableOutputStream
    Buffering output stream that wraps a channel.

    This stream delays channel creation, so if a response will fit in the buffer it is not necessary to set the content length header.

    Author:
    Stuart Douglas
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      void flush()
      long getBytesWritten()  
      void resetBuffer()
      If the response has not yet been written to the client this method will clear the streams buffer, invalidating any content that has already been written.
      void transferFrom​(java.nio.channels.FileChannel source)  
      void write​(byte[] b)
      void write​(byte[] b, int off, int len)
      void write​(int b)
      void write​(java.nio.ByteBuffer byteBuffer)  
      void write​(java.nio.ByteBuffer[] buffers)  
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UndertowOutputStream

        public UndertowOutputStream​(HttpServerExchange exchange)
        Construct a new instance. No write timeout is configured.
        Parameters:
        exchange - The exchange
    • Method Detail

      • resetBuffer

        public void resetBuffer()
        If the response has not yet been written to the client this method will clear the streams buffer, invalidating any content that has already been written. If any content has already been sent to the client then this method will throw and IllegalStateException
        Throws:
        java.lang.IllegalStateException - If the response has been committed
      • getBytesWritten

        public long getBytesWritten()
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(java.nio.ByteBuffer[] buffers)
                   throws java.io.IOException
        Specified by:
        write in interface BufferWritableOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(java.nio.ByteBuffer byteBuffer)
                   throws java.io.IOException
        Specified by:
        write in interface BufferWritableOutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • transferFrom

        public void transferFrom​(java.nio.channels.FileChannel source)
                          throws java.io.IOException
        Specified by:
        transferFrom in interface BufferWritableOutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException