//============================================================================== // NullOutputStream.java //============================================================================== package tribble.io; import java.io.IOException; import java.io.OutputStream; import java.lang.String; /******************************************************************************* * 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 *
*
* * * @version $Revision: 1.3 $ $Date: 2008/09/25 16:43:06 $ * @since 2005-04-05 * @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 NullInputStream */ public class NullOutputStream extends java.io.OutputStream { /** Revision information. */ static final String REV = "@(#)tribble/io/NullOutputStream.java $Revision: 1.3 $ $Date: 2008/09/25 16:43:06 $\n"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Static variables /** A null output stream. */ public static final NullOutputStream NULL_OUT = new NullOutputStream(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Constructors /*************************************************************************** * Default constructor. * * @since 1.1, 2005-04-05 */ public NullOutputStream() { // Initialize } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Methods /*************************************************************************** * Write a byte to the bit bucket. * *

* Note that this method never throws an IOException. * * @param b * An output byte. This is ignored. * * @since 1.1, 2005-04-05 */ public void write(int b) //overrides java.io.OutputStream { // Consume the byte } /*************************************************************************** * Write a set of bytes to the bit bucket. * *

* Note that this method never throws an IOException. * * @param buf * An array of bytes to be written. * The contents of this are ignored. * * @since 1.1, 2005-04-05 */ public void write(/*const*/ byte[] buf) //overrides java.io.OutputStream { // Consume the bytes } /*************************************************************************** * Write a set of bytes to the bit bucket. * *

* Note that this method never throws an IOException. * * @param buf * An array from which bytes are to be written. * The contents of this are ignored. * * @param off * Index of the first byte in buf to write. * * @param len * Number of bytes in buf to write. * * @since 1.1, 2005-04-05 */ public void write(/*const*/ byte[] buf, int off, int len) //overrides java.io.OutputStream { // Consume the bytes } } // End NullOutputStream.java