Package org.apache.commons.io.output
Class ClosedWriter
java.lang.Object
java.io.Writer
org.apache.commons.io.output.ClosedWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Throws an IOException on all attempts to write with
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.
- Since:
- 2.7
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ClosedWriter
Deprecated.static final ClosedWriter
The singleton instance. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
Throws anIOException
to indicate that the stream is closed.void
write
(char[] cbuf, int off, int len) Throws anIOException
to indicate that the writer is closed.
-
Field Details
-
INSTANCE
The singleton instance.- Since:
- 2.12.0
-
CLOSED_WRITER
Deprecated.UseINSTANCE
.The singleton instance.
-
-
Constructor Details
-
ClosedWriter
public ClosedWriter()
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
Throws anIOException
to indicate that the stream is closed.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
- always thrown
-
write
Throws anIOException
to indicate that the writer is closed.- Specified by:
write
in classWriter
- Parameters:
cbuf
- ignoredoff
- ignoredlen
- ignored- Throws:
IOException
- always thrown
-
INSTANCE
.