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
FieldsModifier and TypeFieldDescriptionstatic final ClosedWriterDeprecated.static final ClosedWriterThe singleton instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Throws anIOExceptionto indicate that the stream is closed.voidwrite(char[] cbuf, int off, int len) Throws anIOExceptionto 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
flush
Throws anIOExceptionto indicate that the stream is closed.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException- always thrown
-
write
Throws anIOExceptionto indicate that the writer is closed.- Specified by:
writein classWriter- Parameters:
cbuf- ignoredoff- ignoredlen- ignored- Throws:
IOException- always thrown
-
INSTANCE.