Class NullOutputStream

java.lang.Object
java.io.OutputStream
org.apache.logging.log4j.core.util.NullOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class NullOutputStream extends OutputStream
Writes all data to the famous /dev/null.

This output stream has no destination (file/socket etc.) and all bytes written to it are ignored and lost.

Originally from Apache Commons IO.
Since:
2.3
  • Field Details

  • Method Details

    • getInstance

      public static NullOutputStream getInstance()
      Gets the singleton instance.
      Returns:
      the singleton instance.
    • write

      public void write(byte[] b, int off, int len)
      Does nothing - output to /dev/null.
      Overrides:
      write in class OutputStream
      Parameters:
      b - The bytes to write
      off - The start offset
      len - The number of bytes to write
    • write

      public void write(int b)
      Does nothing - output to /dev/null.
      Specified by:
      write in class OutputStream
      Parameters:
      b - The byte to write
    • write

      public void write(byte[] b) throws IOException
      Does nothing - output to /dev/null.
      Overrides:
      write in class OutputStream
      Parameters:
      b - The bytes to write
      Throws:
      IOException - never