Class java.io.FileInputStream
All Packages    This Package    Previous    Next

Class java.io.FileInputStream

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

public class FileInputStream
extends InputStream
File input stream, can be constructed from a file descriptor or a file name.
See Also:
FileOutputStream, File
Version:
1.13, 17 Feb 1995
Author:
Arthur van Hoff

FileInputStream(String)
Creates an input file given a file name.
FileInputStream(int)
Creates an input file given a file descriptor.
FileInputStream(File)
Creates an input file given a File object.

available()
Returns the number of bytes that can be read without blocking.
close()
Closes the input stream.
finalize()
Close the stream when garbage is collected.
getFD()
Returns the file descriptor associated with this stream.
read()
Reads a byte.
read(byte[])
Reads into an array of bytes.
read(byte[], int, int)
Reads into an array of bytes.
skip(int)
Skips bytes of input.

FileInputStream
  public FileInputStream(String name)
Creates an input file given a file name.
Parameters:
name - the file name (very system dependent)
Throws: IOException
i/o error occurred, file not found

FileInputStream

  public FileInputStream(int fd)
Creates an input file given a file descriptor.
Parameters:
fd - the file descriptor (very system dependent)
Throws: IOException
i/o error occurred

FileInputStream

  public FileInputStream(File file)
Creates an input file given a File object.
Parameters:
file - the file to be opened for reading
Throws: IOException
i/o error occurred, file not found

read
  public int read()
Reads a byte. Will block if no input is available.
Returns:
the byte read, or -1 if the end of the stream is reached.
Throws: IOException
i/o error occurred
Overrides:
read in class InputStream

read

  public int read(byte b[])
Reads into an array of bytes. Blocks until some input is available.
Parameters:
b - the buffer into which the data is read
Returns:
the actual number of bytes read, -1 is returned when the end of the stream is reached.
Throws: IOException
i/o error occurred
Overrides:
read in class InputStream

read

  public int read(byte b[],
                  int off,
                  int len)
Reads into an array of bytes. Blocks until some input is available. For efficiency,this method should be overridden in a subclass (the default implementation reads 1 byte at a time).
Parameters:
b - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes read
Returns:
the actual number of bytes read, -1 is returned when the end of the stream is reached.
Throws: IOException
i/o error occurred
Overrides:
read in class InputStream

skip

  public int skip(int n)
Skips bytes of input.
Parameters:
n - bytes to be skipped
Returns:
actual number of bytes skipped
Throws: IOException
i/o error occurred
Overrides:
skip in class InputStream

available

  public int available()
Returns the number of bytes that can be read without blocking.
Returns:
the number of available bytes, which is initially equal to the file size
Overrides:
available in class InputStream

close

  public synchronized void close()
Closes the input stream. Must be called to release any resources associated with the stream.
Throws: IOException
i/o error occurred
Overrides:
close in class InputStream

getFD

  public final int getFD()
Returns the file descriptor associated with this stream.

finalize

  protected void finalize()
Close the stream when garbage is collected.


All Packages    This Package    Previous    Next