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:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
- Direct Known Subclasses:
TeeWriter
public class ProxyCollectionWriter extends FilterCollectionWriter
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 toFilterWriter
andFilterCollectionWriter
to increase reusability, because FilterWriter changes the methods being called, such aswrite(char[])
towrite(char[], int, int)
andwrite(String)
towrite(String, int, int)
. This is in contrast toProxyWriter
which is backed by a singleWriter
.- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description ProxyCollectionWriter(java.io.Writer... writers)
Creates a new proxy collection writer.ProxyCollectionWriter(java.util.Collection<java.io.Writer> writers)
Creates a new proxy collection writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.Writer
append(char c)
Invokes the delegates'append(char)
methods.java.io.Writer
append(java.lang.CharSequence csq)
Invokes the delegates'append(CharSequence)
methods.java.io.Writer
append(java.lang.CharSequence csq, int start, int end)
Invokes the delegates'append(CharSequence, int, int)
methods.void
close()
Invokes the delegate'sclose()
method.void
flush()
Invokes the delegate'sflush()
method.void
write(char[] cbuf)
Invokes the delegate'swrite(char[])
method.void
write(char[] cbuf, int off, int len)
Invokes the delegate'swrite(char[], int, int)
method.void
write(int c)
Invokes the delegate'swrite(int)
method.void
write(java.lang.String str)
Invokes the delegate'swrite(String)
method.void
write(java.lang.String str, int off, int len)
Invokes the delegate'swrite(String)
method.
-
-
-
Constructor Detail
-
ProxyCollectionWriter
public ProxyCollectionWriter(java.util.Collection<java.io.Writer> writers)
Creates a new proxy collection writer.- Parameters:
writers
- Writers object to provide the underlying targets.
-
ProxyCollectionWriter
public ProxyCollectionWriter(java.io.Writer... writers)
Creates a new proxy collection writer.- Parameters:
writers
- Writers to provide the underlying targets.
-
-
Method Detail
-
append
public java.io.Writer append(char c) throws java.io.IOException
Invokes the delegates'append(char)
methods.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classFilterCollectionWriter
- Parameters:
c
- The character to write- Returns:
- this writer
- Throws:
java.io.IOException
- if an I/O error occurs.- Since:
- 2.0
-
append
public java.io.Writer append(java.lang.CharSequence csq) throws java.io.IOException
Invokes the delegates'append(CharSequence)
methods.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classFilterCollectionWriter
- Parameters:
csq
- The character sequence to write- Returns:
- this writer
- Throws:
java.io.IOException
- if an I/O error occurs.
-
append
public java.io.Writer append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
Invokes the delegates'append(CharSequence, int, int)
methods.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classFilterCollectionWriter
- Parameters:
csq
- The character sequence to writestart
- The index of the first character to writeend
- The index of the first character to write (exclusive)- Returns:
- this writer
- Throws:
java.io.IOException
- if an I/O error occurs.
-
close
public void close() throws java.io.IOException
Invokes the delegate'sclose()
method.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classFilterCollectionWriter
- Throws:
java.io.IOException
- if an I/O error occurs.
-
flush
public void flush() throws java.io.IOException
Invokes the delegate'sflush()
method.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classFilterCollectionWriter
- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(char[] cbuf) throws java.io.IOException
Invokes the delegate'swrite(char[])
method.- Overrides:
write
in classFilterCollectionWriter
- Parameters:
cbuf
- the characters to write- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(char[] cbuf, int off, int len) throws java.io.IOException
Invokes the delegate'swrite(char[], int, int)
method.- Overrides:
write
in classFilterCollectionWriter
- Parameters:
cbuf
- the characters to writeoff
- The start offsetlen
- The number of characters to write- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(int c) throws java.io.IOException
Invokes the delegate'swrite(int)
method.- Overrides:
write
in classFilterCollectionWriter
- Parameters:
c
- the character to write- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(java.lang.String str) throws java.io.IOException
Invokes the delegate'swrite(String)
method.- Overrides:
write
in classFilterCollectionWriter
- Parameters:
str
- the string to write- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(java.lang.String str, int off, int len) throws java.io.IOException
Invokes the delegate'swrite(String)
method.- Overrides:
write
in classFilterCollectionWriter
- Parameters:
str
- the string to writeoff
- The start offsetlen
- The number of characters to write- Throws:
java.io.IOException
- if an I/O error occurs.
-
-