Package org.apache.commons.io.output

# 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`
  `INSTANCE`
  The singleton instance.
  `static final NullWriter`
  `NULL_WRITER`
  Deprecated.
  Use `INSTANCE`.

  ### Fields inherited from class java.io.Writer

  `lock`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NullWriter()`
  Deprecated.
  Use `INSTANCE`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Writer`
  `append(char c)`
  Does nothing - output to `/dev/null`.
  `Writer`
  `append(CharSequence csq)`
  Does nothing - output to `/dev/null`.
  `Writer`
  `append(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(String str)`
  Does nothing - output to `/dev/null`.
  `void`
  `write(String str, int st, int end)`
  Does nothing - output to `/dev/null`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INSTANCE

    public static final NullWriter INSTANCE
    The singleton instance.
    Since:
      2.12.0

  - ### NULL_WRITER

    @Deprecated public static final NullWriter NULL_WRITER
    Deprecated.
    Use `INSTANCE`.
    The singleton instance.

- ## Constructor Details

  - ### NullWriter

    @Deprecated public NullWriter()
    Deprecated.
    Use `INSTANCE`.
    Constructs a new NullWriter.

- ## Method Details

  - ### append

    public Writer append(char c)
    Does nothing - output 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 - output 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 - output to `/dev/null`.
    Specified by:
      `append` in interface `Appendable`
    Overrides:
      `append` in class `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

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Specified by:
      `close` in class `Writer`
    See Also:
      - `Writer.close()`

  - ### flush

    public void flush()
    Specified by:
      `flush` in interface `Flushable`
    Specified by:
      `flush` in class `Writer`
    See Also:
      - `Writer.flush()`

  - ### write

    public void write(char[] chr)
    Does nothing - output to `/dev/null`.
    Overrides:
      `write` in class `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 `Writer`
    Parameters:
      `chr` - The characters to write
      `st` - The start offset
      `end` - The number of characters to write

  - ### write

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

  - ### write

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

  - ### write

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