tribble.io
Class NullInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by tribble.io.NullInputStream
All Implemented Interfaces:
java.io.Closeable

public class NullInputStream
extends java.io.InputStream

Null input stream.

A stream which contains no data, i.e., it always returns end-of-file when attempts are made to read from it. 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.

Since:
2005-04-05
Version:
$Revision: 1.2 $ $Date: 2005/04/06 03:31:02 $
Author:
David R. Tribble (david@tribble.com).
Copyright ©2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
NullOutputStream

Field Summary
static NullInputStream NULL_IN
          A null input stream.
(package private) static java.lang.String REV
          Revision information.
 
Constructor Summary
NullInputStream()
          Default constructor.
 
Method Summary
 int read()
          Read a byte from this (empty) stream.
 int read(byte[] buf)
          Read a set of bytes from this (empty) stream.
 int read(byte[] buf, int off, int len)
          Read a set of bytes from this (empty) stream.
 long skip(long n)
          Skip (discard) a number of bytes from this (empty) stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset
 
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_IN

public static NullInputStream NULL_IN
A null input stream.

Constructor Detail

NullInputStream

public NullInputStream()
Default constructor.

Since:
1.1, 2005-04-05
Method Detail

read

public int read()
Read a byte from this (empty) stream.

Note that this method never throws an IOException.

Specified by:
read in class java.io.InputStream
Returns:
-1 always, indication no more input is available.
Since:
1.1, 2005-04-05

read

public int read(byte[] buf)
Read a set of bytes from this (empty) stream.

Note that this method never throws an IOException.

Overrides:
read in class java.io.InputStream
Parameters:
buf - An array of bytes to be read. The contents of this are not modified.
Returns:
-1 always, indication no more input is available.
Since:
1.1, 2005-04-05

read

public int read(byte[] buf,
                int off,
                int len)
Read a set of bytes from this (empty) stream.

Note that this method never throws an IOException.

Overrides:
read in class java.io.InputStream
Parameters:
buf - An array of bytes to be read. The contents of this are not modified.
off - Index of the first byte in buf to read.
len - Number of bytes in buf to read. This is ignored.
Returns:
-1 always, indication no more input is available.
Since:
1.1, 2005-04-05

skip

public long skip(long n)
Skip (discard) a number of bytes from this (empty) stream.

Note that this method never throws an IOException.

Overrides:
skip in class java.io.InputStream
Parameters:
n - The number of input bytes to skip.
Returns:
The number of bytes skipped, which is always n.
Since:
1.1, 2005-04-05