Class 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 Writer has no destination (file/socket etc.) and all characters written to it are ignored and lost.

    • Constructor Summary

      Constructors 
      Constructor Description
      NullWriter()
      Deprecated.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.Writer append​(char c)
      Does nothing, like writing to /dev/null.
      java.io.Writer append​(java.lang.CharSequence csq)
      Does nothing, like writing to /dev/null.
      java.io.Writer append​(java.lang.CharSequence csq, int start, int end)
      Does nothing except argument validation, like writing to /dev/null.
      void close()  
      void flush()  
      void write​(char[] chr)
      Does nothing except argument validation, like writing to /dev/null.
      void write​(char[] cbuf, int off, int len)
      Does nothing except argument validation, like writing to /dev/null.
      void write​(int b)
      Does nothing, like writing to /dev/null.
      void write​(java.lang.String str)
      Does nothing except argument validation, like writing to /dev/null.
      void write​(java.lang.String str, int off, int len)
      Does nothing except argument validation, like writing to /dev/null.
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NullWriter

        @Deprecated
        public NullWriter()
        Deprecated.
        Constructs a new NullWriter.
    • Method Detail

      • append

        public java.io.Writer append​(char c)
        Does nothing, like writing to /dev/null.
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.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:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.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:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.Writer
        Parameters:
        csq - The character sequence from which a subsequence will be appended. If csq is null, 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:
        this instance.
        Throws:
        java.lang.IndexOutOfBoundsException - If start or end are negative, end is greater than csq.length(), or start is greater than end.
        Since:
        2.0
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
        See Also:
        Writer.close()
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        See Also:
        Writer.flush()
      • write

        public void write​(char[] chr)
        Does nothing except argument validation, like writing to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        chr - The characters to write, not null.
        Throws:
        java.lang.NullPointerException - if chr is null.
      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
        Does nothing except argument validation, like writing to /dev/null.
        Specified by:
        write in class java.io.Writer
        Parameters:
        cbuf - The characters to write, not null.
        off - The start offset.
        len - The number of characters to write.
        Throws:
        java.lang.NullPointerException - if chr is null.
        java.lang.IndexOutOfBoundsException - If (off or len are negative, or off + len is greater than cbuf.length.
      • write

        public void write​(int b)
        Does nothing, like writing to /dev/null.
        Overrides:
        write in class java.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:
        write in class java.io.Writer
        Parameters:
        str - The string to write, not null.
        Throws:
        java.lang.NullPointerException - if str is null.
      • write

        public void write​(java.lang.String str,
                          int off,
                          int len)
        Does nothing except argument validation, like writing to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        str - The string to write, not null.
        off - The start offset.
        len - The number of characters to write.
        Throws:
        java.lang.NullPointerException - If str is null.
        java.lang.IndexOutOfBoundsException - If (off or len are negative, or off + len is greater than str.length().