Package eu.simuline.octave.util
Class TeeWriter
- java.lang.Object
-
- java.io.Writer
-
- eu.simuline.octave.util.TeeWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public final class TeeWriter extends Writer
Executes the actions on a single writer to multiple writers. If the list of writers in the constructor is empty everything that is written will be discarted. If there is thrown one or more exception all writers will still be accessed, the exceptions will be logged and the last exception thrown will be passed on outside.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(char[] cbuf, int off, int len)
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
writers
private final Writer[] writers
-
-
Constructor Detail
-
TeeWriter
public TeeWriter()
Create a writer that doesn't do anything.
-
TeeWriter
public TeeWriter(Writer... writers)
Create a single writer that writes to multiple writers.- Parameters:
writers
- the list of writers that should be written to.
-
-
Method Detail
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
-