public class OutputTwice
extends java.lang.Object
implements java.lang.Appendable, java.io.Closeable, java.io.Flushable
Flushable.flush()
is often necessary and desired,
Closeable.close()
is sometimes necessary.
If the referred outputs are not Closeable or not Flushable, it is not a problem.
But this instance expects now close() as warning also if the referred outputs does not need it.
Advantage: More universal usable, especially for log and reports.Modifier and Type | Field and Description |
---|---|
private java.lang.Appendable |
out1 |
private java.lang.Appendable |
out2 |
Constructor and Description |
---|
OutputTwice(java.lang.Appendable out1,
java.lang.Appendable out2)
Creates
both outputs can be null, prevent output (since 2022-09). |
Modifier and Type | Method and Description |
---|---|
java.lang.Appendable |
append(char c) |
java.lang.Appendable |
append(java.lang.CharSequence csq) |
java.lang.Appendable |
append(java.lang.CharSequence csq,
int start,
int end) |
void |
close() |
void |
flush() |
private final java.lang.Appendable out1
private final java.lang.Appendable out2
public OutputTwice(java.lang.Appendable out1, java.lang.Appendable out2)
out1
- can be a simple StringBuilder, but also any Writerout2
- public java.lang.Appendable append(java.lang.CharSequence csq) throws java.io.IOException
append
in interface java.lang.Appendable
java.io.IOException
public java.lang.Appendable append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
append
in interface java.lang.Appendable
java.io.IOException
public java.lang.Appendable append(char c) throws java.io.IOException
append
in interface java.lang.Appendable
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException