22.4 The Class java.io.FileInputStream

A file input stream obtains input bytes from a file in a file system. What files are available depends on the host environment.

public class FileInputStream extends InputStream  {
	public FileInputStream(String path)
		throws SecurityException, FileNotFoundException;
	public FileInputStream(File file)
		throws SecurityException, FileNotFoundException;
	public FileInputStream(FileDescriptor fdObj)
		throws SecurityException;
	public native int read() throws IOException;
	public int read(byte[] b)
		throws IOException, NullPointerException;
	public int read(byte[] b, int off, int len)
		throws IOException, NullPointerException,
			IndexOutOfBoundsException;
	public native long skip(long n) throws IOException;
	public native int available() throws IOException;
	public native void close() throws IOException;
	public final FileDescriptor getFD() throws IOException;
	protected void finalize() throws IOException;
}

22.4.1 public FileInputStream(String path)
throws SecurityException, FileNotFoundException

This constructor initializes a newly created FileInputStream by opening a connection to an actual file, the file named by the path name path in the file system. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkRead method (§20.17.19) is called with the path argument as its argument.

If the actual file cannot be opened, a FileNotFoundException is thrown.

22.4.2 public FileInputStream(File file)
throws SecurityException, FileNotFoundException

This constructor initializes a newly created FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system. A new FileDescriptor object is created to represent this file connection.

First, if there is a security manager, its checkRead method (§20.17.19) is called with the path represented by the file argument as its argument.

If the actual file cannot be opened, a FileNotFoundException is thrown.

22.4.3 public FileInputStream(FileDescriptor fdObj)
throws SecurityException

This constructor initializes a newly created FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.

First, if there is a security manager, its checkRead method (§20.17.18) is called with the file descriptor fdObj as its argument.

22.4.4 public final FileDescriptor getFD() throws IOException

This method returns the FileDescriptor object (§22.26) that represents the connection to the actual file in the file system being used by this FileInputStream.

22.4.5 public int read() throws IOException;

The byte for this operation is read from the actual file with which this file input stream is connected.

Implements the read method of InputStream (§22.3.1).

22.4.6 public int read(byte[] b)
throws IOException, NullPointerException

Bytes for this operation are read from the actual file with which this file input stream is connected.

Overrides the read method of InputStream (§22.3.2).

22.4.7 public int read(byte[] b, int off, int len)
throws IOException, NullPointerException, IndexOutOfBoundsException

Bytes for this operation are read from the actual file with which this file input stream is connected.

Overrides the read method of InputStream (§22.3.3).

22.4.8 public long skip(long n) throws IOException

Bytes for this operation are read from the actual file with which this file input stream is connected.

Overrides the skip method of InputStream (§22.3.4).

22.4.9 public int available() throws IOException

Overrides the available method of InputStream (§22.3.5).

22.4.10 public void close() throws IOException

This file input stream is closed and may no longer be used for reading bytes.

Overrides the close method of InputStream (§22.3.6).

22.4.11 protected void finalize() throws IOException

A FileInputStream uses finalization to clean up the connection to the actual file.