Class NullOutputStream

java.lang.Object
java.io.OutputStream
com.helger.commons.io.stream.NullOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class NullOutputStream extends OutputStream
An OutputStream that discards all bytes to be written
Author:
Philip Helger
  • Field Details

    • NULL_OUTPUT_STREAM

      public static final NullOutputStream NULL_OUTPUT_STREAM
      A singleton.
  • Constructor Details

    • NullOutputStream

      public NullOutputStream()
      Default constructor. Consider using NULL_OUTPUT_STREAM instead.
  • Method Details

    • 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
    • flush

      public void flush()
      Does not nothing and therefore does not throw an Exception.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
    • close

      public void close()
      Does not nothing and therefore does not throw an Exception.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream