Closeable
, Flushable
, Appendable
, AutoCloseable
StringBufferingWriter
public class DelegatingWriter extends Writer
Modifier and Type | Field | Description |
---|---|---|
protected List<Writer> |
delegates |
The list of
delegate writers to write to. |
Constructor | Description |
---|---|
DelegatingWriter(Writer... delegates) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Delegates the close operation to all delegates and merges any occurred exceptions into a single
IOException . |
void |
flush() |
Delegates the flush operation to all delegates and merges any occurred exceptions into a single
IOException . |
String |
toString() |
|
void |
write(char[] cbuf,
int off,
int len) |
Delegates the write operation to all delegates and merges any occurred exceptions into a single
IOException . |
protected final List<Writer> delegates
delegate writers
to write to.public DelegatingWriter(Writer... delegates)
delegates
- The delegates to write to.public void write(char[] cbuf, int off, int len) throws IOException
IOException
.write
in class Writer
cbuf
- The buffer containing the characters to be written.off
- The offset index to write from.len
- The number of characters to write.IOException
- in case at least one of the delegate writers threw an exception while writing.
Please note: It is very well possible that other delegates were succesfully written.public void flush() throws IOException
IOException
.flush
in interface Flushable
flush
in class Writer
IOException
- in case at least one of the delegate writers threw an exception while flushing.public void close() throws IOException
IOException
.close
in interface AutoCloseable
close
in interface Closeable
close
in class Writer
IOException
- in case at least one of the delegate writers threw an exception while closing.
Please note: Attempts are made to close all delegates.Copyright © 2016–2020 Talsma ICT. All rights reserved.