Package org.apache.commons.io.output
Class ClosedOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.io.output.ClosedOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Throws an IOException on all attempts to write to the stream.
Typically uses of this class include testing for corner cases in methods that accept an output stream and acting as a sentinel value instead of a
null
output stream.
- Since:
- 1.4
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ClosedOutputStream
Deprecated.static final ClosedOutputStream
The singleton instance. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Throws anIOException
to indicate that the stream is closed.void
write
(byte[] b, int off, int len) Throws anIOException
to indicate that the stream is closed.void
write
(int b) Throws anIOException
to indicate that the stream is closed.Methods inherited from class java.io.OutputStream
close, write
-
Field Details
-
INSTANCE
The singleton instance.- Since:
- 2.12.0
-
CLOSED_OUTPUT_STREAM
Deprecated.UseINSTANCE
.The singleton instance.
-
-
Constructor Details
-
ClosedOutputStream
public ClosedOutputStream()
-
-
Method Details
-
flush
Throws anIOException
to indicate that the stream is closed.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- always thrown
-
write
Throws anIOException
to indicate that the stream is closed.- Overrides:
write
in classOutputStream
- Parameters:
b
- ignoredoff
- ignoredlen
- ignored- Throws:
IOException
- always thrown
-
write
Throws anIOException
to indicate that the stream is closed.- Specified by:
write
in classOutputStream
- Parameters:
b
- ignored- Throws:
IOException
- always thrown
-
INSTANCE
.