Package org.apache.commons.io.output
Class FilterCollectionWriter
java.lang.Object
java.io.Writer
org.apache.commons.io.output.FilterCollectionWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
- Direct Known Subclasses:
ProxyCollectionWriter
Abstract class for writing filtered character streams to a
Collection
of writers. This is in contrast to
FilterWriter
which is backed by a single Writer
.
This abstract class provides default methods that pass all requests to the contained writers. Subclasses should likely override some of these methods.
The class Writer
defines method signatures with throws
IOException
, which in this class are
actually IOExceptionList
containing a list of IOIndexedException
.
- Since:
- 2.7
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Collection<Writer>
Empty and immutable collection of writers.protected final Collection<Writer>
The underlying writers. -
Constructor Summary
ModifierConstructorDescriptionprotected
FilterCollectionWriter
(Writer... writers) Constructs a new filtered collection writer.protected
FilterCollectionWriter
(Collection<Writer> writers) Constructs a new filtered collection writer. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
void
flush()
Flushes the stream.void
write
(char[] cbuf) void
write
(char[] cbuf, int off, int len) Writes a portion of an array of characters.void
write
(int c) Writes a single character.void
void
Writes a portion of a string.
-
Field Details
-
EMPTY_WRITERS
Empty and immutable collection of writers. -
writers
The underlying writers.
-
-
Constructor Details
-
FilterCollectionWriter
Constructs a new filtered collection writer.- Parameters:
writers
- Writers to provide the underlying targets.
-
FilterCollectionWriter
Constructs a new filtered collection writer.- Parameters:
writers
- Writers to provide the underlying targets.
-
-
Method Details
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
Flushes the stream.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
- If an I/O error occurs
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
Writes a portion of an array of characters.- Specified by:
write
in classWriter
- Parameters:
cbuf
- Buffer of characters to be writtenoff
- Offset from which to start reading characterslen
- Number of characters to be written- Throws:
IOException
- If an I/O error occurs
-
write
Writes a single character.- Overrides:
write
in classWriter
- Throws:
IOException
- If an I/O error occurs
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
Writes a portion of a string.- Overrides:
write
in classWriter
- Parameters:
str
- String to be writtenoff
- Offset from which to start reading characterslen
- Number of characters to be written- Throws:
IOException
- If an I/O error occurs
-