Class ProxyOutputStream

java.lang.Object
java.io.OutputStream
net.logstash.logback.util.ProxyOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class ProxyOutputStream extends OutputStream
A Proxy stream which acts as expected, that is it passes the method calls on to the proxied stream and doesn't change which methods are being called (unlike JDK FilterOutputStream).

Note: This class is for internal use only and subject to backward incompatible change at any time.

Author:
brenuart
  • Field Details

  • Constructor Details

    • ProxyOutputStream

      public ProxyOutputStream(OutputStream delegate)
      Constructs a new ProxyOutputStream.
      Parameters:
      delegate - the OutputStream to delegate to
  • Method Details

    • write

      public void write(int b) throws IOException
      Invokes the delegate's write(int) method.
      Specified by:
      write in class OutputStream
      Parameters:
      b - the byte to write
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(byte[] b) throws IOException
      Invokes the delegate's write(byte[]) method.
      Overrides:
      write in class OutputStream
      Parameters:
      b - the bytes to write
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Invokes the delegate's write(byte[]) method.
      Overrides:
      write in class OutputStream
      Parameters:
      b - the bytes to write
      off - The start offset
      len - The number of bytes to write
      Throws:
      IOException - if an I/O error occurs
    • flush

      public void flush() throws IOException
      Invokes the delegate's flush() method.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException - if an I/O error occurs
    • close

      public void close() throws IOException
      Invokes the delegate's close() method.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException - if an I/O error occurs
    • handleIOException

      protected void handleIOException(IOException e) throws IOException
      Handle any IOExceptions thrown.

      This method provides a point to implement custom exception handling. The default behavior is to re-throw the exception.

      Parameters:
      e - The IOException thrown
      Throws:
      IOException - if an I/O error occurs
    • assertStreamConnected

      protected OutputStream assertStreamConnected() throws IOException
      Get the underlying OutputStream and assert it is connected.
      Returns:
      the underlying OutputStream
      Throws:
      IOException - thrown when the stream is not connected