public class ClosedWriter extends Writer
close()
implemented as a noop.
Typically uses of this class include testing for corner cases in methods that accept a writer and acting as a
sentinel value instead of a null
writer.
Modifier and Type | Field and Description |
---|---|
static ClosedWriter |
CLOSED_WRITER
Deprecated.
Use
INSTANCE . |
static ClosedWriter |
INSTANCE
The singleton instance.
|
Constructor and Description |
---|
ClosedWriter() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush()
Throws an
IOException to indicate that the stream is closed. |
void |
write(char[] cbuf,
int off,
int len)
Throws an
IOException to indicate that the writer is closed. |
public static final ClosedWriter INSTANCE
@Deprecated public static final ClosedWriter CLOSED_WRITER
INSTANCE
.public ClosedWriter()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
public void flush() throws IOException
IOException
to indicate that the stream is closed.flush
in interface Flushable
flush
in class Writer
IOException
- always thrownpublic void write(char[] cbuf, int off, int len) throws IOException
IOException
to indicate that the writer is closed.write
in class Writer
cbuf
- ignoredoff
- ignoredlen
- ignoredIOException
- always thrownCopyright © 2002–2023 The Apache Software Foundation. All rights reserved.