Package org.apache.commons.io.output
Class ProxyCollectionWriter
java.lang.Object
java.io.Writer
org.apache.commons.io.output.FilterCollectionWriter
org.apache.commons.io.output.ProxyCollectionWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
- Direct Known Subclasses:
- TeeWriter
A Proxy stream collection which acts as expected, that is it passes the method calls on to the proxied streams and
 doesn't change which methods are being called. It is an alternative base class to 
FilterWriter and
 FilterCollectionWriter to increase reusability, because FilterWriter changes the methods being called, such
 as write(char[]) to write(char[], int, int) and write(String) to
 write(String, int, int). This is in contrast to ProxyWriter which is backed by a single
 Writer.- Since:
- 2.7
- 
Field SummaryFields inherited from class org.apache.commons.io.output.FilterCollectionWriterEMPTY_WRITERS, writers
- 
Constructor SummaryConstructorsConstructorDescriptionProxyCollectionWriter(Writer... writers) Constructs a new proxy collection writer.ProxyCollectionWriter(Collection<Writer> writers) Constructs a new proxy collection writer.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidafterWrite(int n) Invoked by the write methods after the proxied call has returned successfully.append(char c) Invokes the delegates'append(char)methods.append(CharSequence csq) Invokes the delegates'append(CharSequence)methods.append(CharSequence csq, int start, int end) Invokes the delegates'append(CharSequence, int, int)methods.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.voidwrite(char[] cbuf) Invokes the delegate'swrite(char[])method.voidwrite(char[] cbuf, int off, int len) Invokes the delegate'swrite(char[], int, int)method.voidwrite(int c) Invokes the delegate'swrite(int)method.voidInvokes the delegate'swrite(String)method.voidInvokes the delegate'swrite(String)method.
- 
Constructor Details- 
ProxyCollectionWriterConstructs a new proxy collection writer.- Parameters:
- writers- Writers object to provide the underlying targets.
 
- 
ProxyCollectionWriterConstructs a new proxy collection writer.- Parameters:
- writers- Writers to provide the underlying targets.
 
 
- 
- 
Method Details- 
afterWriteInvoked by the write methods after the proxied call has returned successfully. The number of chars written (1 for thewrite(int)method, buffer length forwrite(char[]), 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 chars written
- Throws:
- IOException- if the post-processing fails
 
- 
appendInvokes the delegates'append(char)methods.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- FilterCollectionWriter
- Parameters:
- c- The character to write
- Returns:
- this writer
- Throws:
- IOException- if an I/O error occurs.
- Since:
- 2.0
 
- 
appendInvokes the delegates'append(CharSequence)methods.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- FilterCollectionWriter
- Parameters:
- csq- The character sequence to write
- Returns:
- this writer
- Throws:
- IOException- if an I/O error occurs.
 
- 
appendInvokes the delegates'append(CharSequence, int, int)methods.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- FilterCollectionWriter
- Parameters:
- csq- The character sequence to write
- start- The index of the first character to write
- end- The index of the first character to write (exclusive)
- Returns:
- this writer
- Throws:
- IOException- if an I/O error occurs.
 
- 
beforeWriteInvoked by the write methods before the call is proxied. The number of chars to be written (1 for thewrite(int)method, buffer length forwrite(char[]), 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 chars to be written
- Throws:
- IOException- if the pre-processing fails
 
- 
closeInvokes the delegate'sclose()method.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- FilterCollectionWriter
- Throws:
- IOException- if an I/O error occurs.
 
- 
flushInvokes the delegate'sflush()method.- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- FilterCollectionWriter
- 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.
 
- 
writeInvokes the delegate'swrite(char[])method.- Overrides:
- writein class- FilterCollectionWriter
- Parameters:
- cbuf- the characters to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(char[], int, int)method.- Overrides:
- writein class- FilterCollectionWriter
- Parameters:
- cbuf- the characters to write
- off- The start offset
- len- The number of characters to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(int)method.- Overrides:
- writein class- FilterCollectionWriter
- Parameters:
- c- the character to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(String)method.- Overrides:
- writein class- FilterCollectionWriter
- Parameters:
- str- the string to write
- Throws:
- IOException- if an I/O error occurs.
 
- 
writeInvokes the delegate'swrite(String)method.- Overrides:
- writein class- FilterCollectionWriter
- Parameters:
- str- the string to write
- off- The start offset
- len- The number of characters to write
- Throws:
- IOException- if an I/O error occurs.
 
 
-