tribble.io
Class NullOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by tribble.io.NullOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class NullOutputStream
extends java.io.OutputStream

Null output stream (data sink).

A stream which ignores all output written to it, i.e., it sends all data written to it into the bit bucket. This is similar to the Unix/POSIX /dev/null device or the MS-DOS nul file.

Note that none of the methods throw an IOException.

Source code:
Available at: http://david.tribble.com/src/java/tribble/io/NullOutputStream.java
Documentation:
Available at: http://david.tribble.com/docs/tribble/io/NullOutputStream.html

Since:
2005-04-05
Version:
$Revision: 1.3 $ $Date: 2008/09/25 16:43:06 $
Author:
David R. Tribble (david@tribble.com)

Copyright ©2005-2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by by the United States Department of State as a terrorist, or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.

See Also:
NullInputStream

Field Summary
static NullOutputStream NULL_OUT
          A null output stream.
(package private) static java.lang.String REV
          Revision information.
 
Constructor Summary
NullOutputStream()
          Default constructor.
 
Method Summary
 void write(byte[] buf)
          Write a set of bytes to the bit bucket.
 void write(byte[] buf, int off, int len)
          Write a set of bytes to the bit bucket.
 void write(int b)
          Write a byte to the bit bucket.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

NULL_OUT

public static final NullOutputStream NULL_OUT
A null output stream.

Constructor Detail

NullOutputStream

public NullOutputStream()
Default constructor.

Since:
1.1, 2005-04-05
Method Detail

write

public void write(int b)
Write a byte to the bit bucket.

Note that this method never throws an IOException.

Specified by:
write in class java.io.OutputStream
Parameters:
b - An output byte. This is ignored.
Since:
1.1, 2005-04-05

write

public void write(byte[] buf)
Write a set of bytes to the bit bucket.

Note that this method never throws an IOException.

Overrides:
write in class java.io.OutputStream
Parameters:
buf - An array of bytes to be written. The contents of this are ignored.
Since:
1.1, 2005-04-05

write

public void write(byte[] buf,
                  int off,
                  int len)
Write a set of bytes to the bit bucket.

Note that this method never throws an IOException.

Overrides:
write in class java.io.OutputStream
Parameters:
buf - An array from which bytes are to be written. The contents of this are ignored.
off - Index of the first byte in buf to write.
len - Number of bytes in buf to write.
Since:
1.1, 2005-04-05