Package org.apache.commons.io.output
Class NullWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.commons.io.output.NullWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.Appendable,java.lang.AutoCloseable
public class NullWriter extends java.io.Writer
Never writes data. Calls never go beyond this class.This
Writerhas no destination (file/socket etc.) and all characters written to it are ignored and lost.
-
-
Field Summary
Fields Modifier and Type Field Description static NullWriterINSTANCEThe singleton instance.static NullWriterNULL_WRITERDeprecated.UseINSTANCE.
-
Constructor Summary
Constructors Constructor Description NullWriter()Deprecated.UseINSTANCE.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.Writerappend(char c)Does nothing, like writing to/dev/null.java.io.Writerappend(java.lang.CharSequence csq)Does nothing, like writing to/dev/null.java.io.Writerappend(java.lang.CharSequence csq, int start, int end)Does nothing except argument validation, like writing to/dev/null.voidclose()voidflush()voidwrite(char[] chr)Does nothing except argument validation, like writing to/dev/null.voidwrite(char[] cbuf, int off, int len)Does nothing except argument validation, like writing to/dev/null.voidwrite(int b)Does nothing, like writing to/dev/null.voidwrite(java.lang.String str)Does nothing except argument validation, like writing to/dev/null.voidwrite(java.lang.String str, int off, int len)Does nothing except argument validation, like writing to/dev/null.
-
-
-
Field Detail
-
INSTANCE
public static final NullWriter INSTANCE
The singleton instance.- Since:
- 2.12.0
-
NULL_WRITER
@Deprecated public static final NullWriter NULL_WRITER
Deprecated.UseINSTANCE.The singleton instance.
-
-
Constructor Detail
-
NullWriter
@Deprecated public NullWriter()
Deprecated.UseINSTANCE.Constructs a new NullWriter.
-
-
Method Detail
-
append
public java.io.Writer append(char c)
Does nothing, like writing to/dev/null.- Specified by:
appendin interfacejava.lang.Appendable- Overrides:
appendin classjava.io.Writer- Parameters:
c- The character to write.- Returns:
- this writer.
- Since:
- 2.0
-
append
public java.io.Writer append(java.lang.CharSequence csq)
Does nothing, like writing to/dev/null.- Specified by:
appendin interfacejava.lang.Appendable- Overrides:
appendin classjava.io.Writer- Parameters:
csq- The character sequence to write.- Returns:
- this writer
- Since:
- 2.0
-
append
public java.io.Writer append(java.lang.CharSequence csq, int start, int end)
Does nothing except argument validation, like writing to/dev/null.- Specified by:
appendin interfacejava.lang.Appendable- Overrides:
appendin classjava.io.Writer- Parameters:
csq- The character sequence from which a subsequence will be appended. Ifcsqisnull, it is treated as if it were"null".start- The index of the first character in the subsequence.end- The index of the character following the last character in the subsequence.- Returns:
thisinstance.- Throws:
java.lang.IndexOutOfBoundsException- Ifstartorendare negative,endis greater thancsq.length(), orstartis greater thanend.- Since:
- 2.0
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Writer- See Also:
Writer.close()
-
flush
public void flush()
- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classjava.io.Writer- See Also:
Writer.flush()
-
write
public void write(char[] chr)
Does nothing except argument validation, like writing to/dev/null.- Overrides:
writein classjava.io.Writer- Parameters:
chr- The characters to write, notnull.- Throws:
java.lang.NullPointerException- ifchrisnull.
-
write
public void write(char[] cbuf, int off, int len)
Does nothing except argument validation, like writing to/dev/null.- Specified by:
writein classjava.io.Writer- Parameters:
cbuf- The characters to write, notnull.off- The start offset.len- The number of characters to write.- Throws:
java.lang.NullPointerException- ifchrisnull.java.lang.IndexOutOfBoundsException- If (offorlenare negative, oroff + lenis greater thancbuf.length.
-
write
public void write(int b)
Does nothing, like writing to/dev/null.- Overrides:
writein classjava.io.Writer- Parameters:
b- The character to write.
-
write
public void write(java.lang.String str)
Does nothing except argument validation, like writing to/dev/null.- Overrides:
writein classjava.io.Writer- Parameters:
str- The string to write, notnull.- Throws:
java.lang.NullPointerException- ifstrisnull.
-
write
public void write(java.lang.String str, int off, int len)
Does nothing except argument validation, like writing to/dev/null.- Overrides:
writein classjava.io.Writer- Parameters:
str- The string to write, notnull.off- The start offset.len- The number of characters to write.- Throws:
java.lang.NullPointerException- Ifstrisnull.java.lang.IndexOutOfBoundsException- If (offorlenare negative, oroff + lenis greater thanstr.length().
-
-