Class NullWriter

java.lang.Object
java.io.Writer
org.apache.commons.io.output.NullWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class NullWriter extends 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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NullWriter
    The singleton instance.
    static final NullWriter
    Deprecated.

    Fields inherited from class Writer

    lock
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(char c)
    Does nothing, like writing to /dev/null.
    Does nothing, like writing to /dev/null.
    append(CharSequence csq, int start, int end)
    Does nothing except argument validation, like writing to /dev/null.
    void
     
    void
     
    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
    Does nothing except argument validation, like writing to /dev/null.
    void
    write(String str, int off, int len)
    Does nothing except argument validation, like writing to /dev/null.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • append

      public Writer append(char c)
      Does nothing, like writing to /dev/null.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      c - The character to write.
      Returns:
      this writer.
      Since:
      2.0
    • append

      public Writer append(CharSequence csq)
      Does nothing, like writing to /dev/null.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      csq - The character sequence to write.
      Returns:
      this writer
      Since:
      2.0
    • append

      public Writer append(CharSequence csq, int start, int end)
      Does nothing except argument validation, like writing to /dev/null.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class 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:
      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 AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
      See Also:
    • flush

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

      public void write(char[] chr)
      Does nothing except argument validation, like writing to /dev/null.
      Overrides:
      write in class Writer
      Parameters:
      chr - The characters to write, not null.
      Throws:
      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 Writer
      Parameters:
      cbuf - The characters to write, not null.
      off - The start offset.
      len - The number of characters to write.
      Throws:
      NullPointerException - if chr is null.
      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 Writer
      Parameters:
      b - The character to write.
    • write

      public void write(String str)
      Does nothing except argument validation, like writing to /dev/null.
      Overrides:
      write in class Writer
      Parameters:
      str - The string to write, not null.
      Throws:
      NullPointerException - if str is null.
    • write

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