Package net.logstash.logback.util
Class ProxyOutputStream
java.lang.Object
java.io.OutputStream
net.logstash.logback.util.ProxyOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProxyOutputStream
(OutputStream delegate) Constructs a new ProxyOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected OutputStream
Get the underlying OutputStream and assert it is connected.void
close()
Invokes the delegate'sclose()
method.void
flush()
Invokes the delegate'sflush()
method.protected void
Handle any IOExceptions thrown.void
write
(byte[] b) Invokes the delegate'swrite(byte[])
method.void
write
(byte[] b, int off, int len) Invokes the delegate'swrite(byte[])
method.void
write
(int b) Invokes the delegate'swrite(int)
method.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
delegate
-
-
Constructor Details
-
ProxyOutputStream
Constructs a new ProxyOutputStream.- Parameters:
delegate
- the OutputStream to delegate to
-
-
Method Details
-
write
Invokes the delegate'swrite(int)
method.- Specified by:
write
in classOutputStream
- Parameters:
b
- the byte to write- Throws:
IOException
- if an I/O error occurs
-
write
Invokes the delegate'swrite(byte[])
method.- Overrides:
write
in classOutputStream
- Parameters:
b
- the bytes to write- Throws:
IOException
- if an I/O error occurs
-
write
Invokes the delegate'swrite(byte[])
method.- Overrides:
write
in classOutputStream
- Parameters:
b
- the bytes to writeoff
- The start offsetlen
- The number of bytes to write- Throws:
IOException
- if an I/O error occurs
-
flush
Invokes the delegate'sflush()
method.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs
-
close
Invokes the delegate'sclose()
method.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
- if an I/O error occurs
-
handleIOException
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
Get the underlying OutputStream and assert it is connected.- Returns:
- the underlying OutputStream
- Throws:
IOException
- thrown when the stream is not connected
-