Class NullWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class NullWriter
    extends java.io.Writer
    Writes all data to the famous /dev/null.

    This Writer has no destination (file/socket etc.) and all characters written to it are ignored and lost.

    • Constructor Summary

      Constructors 
      Constructor Description
      NullWriter()
      Constructs a new NullWriter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.Writer append​(char c)
      Does nothing - output to /dev/null.
      java.io.Writer append​(java.lang.CharSequence csq)
      Does nothing - output to /dev/null.
      java.io.Writer append​(java.lang.CharSequence csq, int start, int end)
      Does nothing - output to /dev/null.
      void close()  
      void flush()  
      void write​(char[] chr)
      Does nothing - output to /dev/null.
      void write​(char[] chr, int st, int end)
      Does nothing - output to /dev/null.
      void write​(int idx)
      Does nothing - output to /dev/null.
      void write​(java.lang.String str)
      Does nothing - output to /dev/null.
      void write​(java.lang.String str, int st, int end)
      Does nothing - output to /dev/null.
      • Methods inherited from class java.io.Writer

        nullWriter
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NULL_WRITER

        public static final NullWriter NULL_WRITER
        A singleton.
    • Constructor Detail

      • NullWriter

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

      • append

        public java.io.Writer append​(char c)
        Does nothing - output 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,
                                     int start,
                                     int end)
        Does nothing - output 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
        start - The index of the first character to write
        end - The index of the first character to write (exclusive)
        Returns:
        this writer
        Since:
        2.0
      • append

        public java.io.Writer append​(java.lang.CharSequence csq)
        Does nothing - output 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
      • write

        public void write​(int idx)
        Does nothing - output to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        idx - The character to write
      • write

        public void write​(char[] chr)
        Does nothing - output to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        chr - The characters to write
      • write

        public void write​(char[] chr,
                          int st,
                          int end)
        Does nothing - output to /dev/null.
        Specified by:
        write in class java.io.Writer
        Parameters:
        chr - The characters to write
        st - The start offset
        end - The number of characters to write
      • write

        public void write​(java.lang.String str)
        Does nothing - output to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        str - The string to write
      • write

        public void write​(java.lang.String str,
                          int st,
                          int end)
        Does nothing - output to /dev/null.
        Overrides:
        write in class java.io.Writer
        Parameters:
        str - The string to write
        st - The start offset
        end - The number of characters to write
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        See Also:
        Writer.flush()
      • 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()