Package org.apache.commons.io.output
Class ProxyOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.io.output.ProxyOutputStream
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
- Direct Known Subclasses:
- CloseShieldOutputStream,- CountingOutputStream,- TaggedOutputStream,- TeeOutputStream
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. It is an alternative base class to FilterOutputStream
 to increase reusability.
 
See the protected methods for ways in which a subclass can easily decorate a stream with custom pre-, post- or error processing functionality.
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields inherited from class java.io.FilterOutputStreamout
- 
Constructor SummaryConstructorsConstructorDescriptionProxyOutputStream(OutputStream delegate) Constructs a new ProxyOutputStream.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidafterWrite(int n) Invoked by the write methods after the proxied call has returned successfully.protected voidbeforeWrite(int n) Invoked by the write methods before the call is proxied.voidclose()Invokes the delegate'sclose()method.voidflush()Invokes the delegate'sflush()method.protected voidHandle any IOExceptions thrown.setReference(OutputStream out) Sets the underlying output stream.voidwrite(byte[] bts) Invokes the delegate'swrite(byte[])method.voidwrite(byte[] bts, int st, int end) Invokes the delegate'swrite(byte[])method.voidwrite(int b) Invokes the delegate'swrite(int)method.
- 
Constructor Details- 
ProxyOutputStreamConstructs a new ProxyOutputStream.- Parameters:
- delegate- the OutputStream to delegate to
 
 
- 
- 
Method Details- 
afterWriteInvoked by the write methods after the proxied call has returned successfully. The number of bytes written (1 for thewrite(int)method, buffer length forwrite(byte[]), etc.) is given as an argument.Subclasses can override this method to add common post-processing functionality without having to override all the write methods. The default implementation does nothing. - Parameters:
- n- number of bytes written
- Throws:
- IOException- if the post-processing fails
- Since:
- 2.0
 
- 
beforeWriteInvoked by the write methods before the call is proxied. The number of bytes to be written (1 for thewrite(int)method, buffer length forwrite(byte[]), etc.) is given as an argument.Subclasses can override this method to add common pre-processing functionality without having to override all the write methods. The default implementation does nothing. - Parameters:
- n- number of bytes to be written
- Throws:
- IOException- if the pre-processing fails
- Since:
- 2.0
 
- 
closeInvokes the delegate'sclose()method.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- FilterOutputStream
- Throws:
- IOException- if an I/O error occurs.
 
- 
flushInvokes the delegate'sflush()method.- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- FilterOutputStream
- Throws:
- IOException- if an I/O error occurs.
 
- 
handleIOExceptionHandle 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.
- Since:
- 2.0
 
- 
setReferenceSets the underlying output stream.- Parameters:
- out- the underlying output stream.
- Returns:
- this instance.
- Since:
- 2.19.0
 
- 
writeInvokes the delegate'swrite(byte[])method.- Overrides:
- writein class- FilterOutputStream
- Parameters:
- bts- the bytes to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(byte[])method.- Overrides:
- writein class- FilterOutputStream
- Parameters:
- bts- the bytes to write
- st- The start offset
- end- The number of bytes to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(int)method.- Overrides:
- writein class- FilterOutputStream
- Parameters:
- b- the byte to write
- Throws:
- IOException- if an I/O error occurs.
 
 
-