things.thinger.io
Class EmptyInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by things.thinger.io.EmptyInputStream
All Implemented Interfaces:
java.io.Closeable

public class EmptyInputStream
extends java.io.InputStream

Empty input stream. It will never yield anything.

Version:
1.0

Version History

EPG - Initial - 12 FEB 07
 
Author:
Erich P. Gatejen

Constructor Summary
EmptyInputStream()
           
 
Method Summary
 int available()
          Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
 void close()
          Close the stream.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Reads some number of bytes from the input stream and stores them into the buffer array b.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyInputStream

public EmptyInputStream()
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Specified by:
read in class java.io.InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

Overrides:
read in class java.io.InputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset in array b at which the data is written.
len - the maximum number of bytes to read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
If - the first byte cannot be read for any reason other than end of file or if some other I/O error occurs.
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

Overrides:
read in class java.io.InputStream
Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
If - the first byte cannot be read for any reason other than end of file or if some other I/O error occurs.
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the stream. It will NOT deplete the stream. However, all subsequent calls to reads will yield EOF and any internal references to the stream will be cleared.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - All subsequent calls to the reads will result in EOF.

available

public int available()
              throws java.io.IOException
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Overrides:
available in class java.io.InputStream
Returns:
number of bytes available.
Throws:
IO - exception
java.io.IOException


Things.