java.io
Class FileInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FileInputStream

public class FileInputStream
extends InputStream

FileInputStream provides the functionality to read from files.


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

Constructor Detail

FileInputStream

public FileInputStream(File f)
Creates a new FileInputStream to read from the specified file.


FileInputStream

public FileInputStream(String name)
Creates a new FileInputStream to read from the specified file.

Parameters:
name - Name of the file to read.
Method Detail

available

public int available()
              throws IOException
Returns the number of bytes that can be read without blocking.

Overrides:
available in class InputStream
Returns:
number of bytes
IOException

close

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

Overrides:
close in class InputStream
IOException

read

public int read()
         throws IOException
Reads a single byte from this input stream. If there is no byte available this method will block and wait for the next available byte. EASy's implementation of this method first checks if there is a byte available. If this is not the case the current thread will be put to sleep for some milliseconds before it will check for available data again. This behaviour allows smooth multithreading - EASy threads cannot be interrupted within native code.

Specified by:
read in class InputStream
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[] b,
                int off,
                int len)
         throws IOException
Reads up to len bytes from the stream into bytes, at offset ofs.

Overrides:
read in class InputStream
Parameters:
len - Length of data to be read.
b - Array to be filled with data read.
off - Offset into b where to start writing the read data.
Returns:
The number of bytes read; -1 if there are no more bytes to read.
Throws:
IOException - if an I/O error occurs.
IndexOutOfBoundsException - if ofs is negative, of len is neagitve, or ofs+len exceeds the array.

skip

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

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

skip

public int skip(int 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.