@MinDoc(copyright="Copyright 2001 - 2002, 2009 A. Weinert", author="Albrecht Weinert", version="V.32", lastModified="22.03.2021", usage="use where a Writer or PrintWriter but not the output is needed", purpose="a sink for text, that forgets the content") public class BlackHoleWriter extends Writer
Writer
or PrintWriter
is called for or needed, but the output is of no concern (or if one
needs the instrumentation).Modifier and Type | Field and Description |
---|---|
int |
charsWritten
The number of written (and forgotten) characters
|
protected boolean |
closed
Closed.
|
boolean |
flushed
flush() was called.
|
PrintWriter |
vPw
The decorating PrintWriter.
|
boolean |
written
One of the methods write() was called.
|
Constructor and Description |
---|
BlackHoleWriter(boolean autoflush)
Making the BlackHoleWriter.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closing the BlackHoleWriter.
|
void |
flush()
Flushing the BlackHoleWriter.
|
PrintWriter |
getPrintWriter()
The decorating PrintWriter.
|
boolean |
isClosed()
Closed.
|
void |
write(char c)
Writing a character to the BlackHoleWriter.
|
void |
write(char[] cbuf)
Writing of a char[] array to the BlackHoleWriter.
|
void |
write(char[] cbuf,
int off,
int len)
Writing of a char[] array to the BlackHoleWriter.
|
void |
write(int ic)
Writing of a char (provided as int) to the BlackHoleWriter.
|
public final PrintWriter vPw
getPrintWriter()
protected volatile boolean closed
close()
.charsWritten
is frozen. Subsequent
calls to one of the methods write()
do nothing (not even
counting); they also throw no exception, as would happen on other types
of closed streams.public volatile boolean flushed
public volatile boolean written
public volatile int charsWritten
public BlackHoleWriter(boolean autoflush)
autoflush
- decides, if the decorating PrintWriter uses
automatic flushing.public PrintWriter getPrintWriter()
PrintWriter
instead of
a"naked" Writer
may be called for (even if
writing to the dump with formatting seems double waste).public boolean isClosed()
close()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
isClosed()
public void flush()
public void write(char[] cbuf, int off, int len)
public void write(char[] cbuf)
public void write(int ic)
public void write(char c)
Writer
as is
TeeWriter
.write(char)
.