java.io
Class InputStream

java.lang.Object
  |
  +--java.io.InputStream
Direct Known Subclasses:
FileInputStream, FilterInputStream

public abstract class InputStream
extends Object

This abstract class is the superclass of all classes representing an input stream of bytes.


Constructor Summary
InputStream()
          Default constructor.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blocking.
 void close()
          Closes this input stream and releases all system resources associated with it.
abstract  int read()
          Reads a single byte from this input stream.
 int read(byte[] bytes)
          Reads up to b.length bytes from this stream into b.
 int read(byte[] bytes, int ofs, int len)
          Reads up to len bytes from this stream into b starting at offset ofs.
 long skip(long n)
          Skips over and discards n bytes from the input stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 

Constructor Detail

InputStream

public InputStream()
Default constructor.

Method Detail

available

public int available()
              throws IOException
Returns the number of bytes that can be read without blocking. Returning 0 means that blocking might or might not occur. The method in this class always returns 0.

Returns:
number of bytes
IOException

close

public void close()
           throws IOException
Closes this input stream and releases all system resources associated with it.

IOException

read

public abstract int read()
                  throws IOException
Reads a single byte from this input stream. This abstract method shall be overloaded by subclasses.

Returns:
The next byte of data; -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.

read

public int read(byte[] bytes)
         throws IOException
Reads up to b.length bytes from this stream into b. The method returns under the following conditions: 1. the array is completly filled, 2. there are no more bytes available, 3. a carriage return is read. If b was not completly filled, the remaining bytes of b still contain the values from before this method was called.

Parameters:
bytes - Array to be filled with data read.
Returns:
The number of bytes read; -1 if there are no more bytes to read.
Throws:
IOException - if an I/O error occurs.

read

public int read(byte[] bytes,
                int ofs,
                int len)
         throws IOException
Reads up to len bytes from this stream into b starting at offset ofs. The method returns under the following conditions: 1. len bytes have been read, 2. there are no more bytes available, 3. a carriage return is read.

Parameters:
bytes - Array to be filled with data read.
ofs - Offset into b where to start writing the read data.
len - Number of bytes to be read.
Returns:
The number of bytes read; -1 if there are no more bytes to read.
Throws:
IndexOutOfBoundsException - when either ofs or len are smaller than 0 or ofs+len exceed the array's length.
IOException - if an I/O error occurs.

skip

public long skip(long n)
          throws IOException
Skips over and discards n bytes from the input stream.

Parameters:
n - Number of bytes to overread.
Returns:
The number of bytes overread.
Throws:
IOException - if an I/O error occurs.