Package org.apache.commons.io.output
Class NullOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.commons.io.output.NullOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class NullOutputStream extends java.io.OutputStream
Never writes data. Calls never go beyond this class.This output stream has no destination and all bytes written to it are ignored.
-
-
Field Summary
Fields Modifier and Type Field Description static NullOutputStreamINSTANCEThe singleton instance.static NullOutputStreamNULL_OUTPUT_STREAMDeprecated.UseINSTANCE.
-
Constructor Summary
Constructors Constructor Description NullOutputStream()Deprecated.UseINSTANCE.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidwrite(byte[] b)Does nothing.voidwrite(byte[] b, int off, int len)No-op operation.voidwrite(int b)Does nothing.
-
-
-
Field Detail
-
INSTANCE
public static final NullOutputStream INSTANCE
The singleton instance.- Since:
- 2.12.0
-
NULL_OUTPUT_STREAM
@Deprecated public static final NullOutputStream NULL_OUTPUT_STREAM
Deprecated.UseINSTANCE.The singleton instance.
-
-
Constructor Detail
-
NullOutputStream
@Deprecated public NullOutputStream()
Deprecated.UseINSTANCE.Deprecated in favor ofINSTANCE.TODO: Will be private in 3.0.
-
-
Method Detail
-
write
public void write(byte[] b) throws java.io.IOException
Does nothing.- Overrides:
writein classjava.io.OutputStream- Parameters:
b- The This method ignores this parameter.- Throws:
java.io.IOException- This method never throws any exceptions.
-
write
public void write(byte[] b, int off, int len)
No-op operation.Validates the arguments but does not write the data.
- Overrides:
writein classjava.io.OutputStream- Parameters:
b- The byte array to write from, notnull.off- The offset to start at.len- The number of bytes to write.- Throws:
java.lang.NullPointerException- Ifbisnull.java.lang.IndexOutOfBoundsException- Ifofforlenare negative,off + lenis greater thanb.length.
-
write
public void write(int b)
Does nothing.- Specified by:
writein classjava.io.OutputStream- Parameters:
b- This method ignores this parameter.
-
-