Package java.io |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public class java.io.FileInputStream extends java.io.InputStream { // Constructors public FileInputStream(File file); public FileInputStream(FileDescriptor fdObj); public FileInputStream(String name); // Methods public int available(); public void close(); protected void finalize(); public final FileDescriptor getFD(); public int read(); public int read(byte b[]); public int read(byte b[], int off, int len); public long skip(long n); }
A file input stream is an input stream for reading data from a File or from a FileDescriptor .
public FileInputStream(File file)throws FileNotFoundExceptionCreates an input file stream to read from the specified File object
Parameter Description file the file to be opened for reading Throw:
If the file is not found.
Throw:
If a security manager exists, its checkRead method is called with the path name of this File argument to see if the application is allowed read access to the file. This may result in a security exception .
public FileInputStream(FileDescriptor fdObj)Creates an input file stream to read from the specified file descriptor
Parameter Description fdObj the file descriptor to be opened for reading Throw:
If a security manager exists, its checkRead method is called with the file descriptor to see if the application is allowed to read from the specified file descriptor. This may result in a security exception .
public FileInputStream(String name)throws FileNotFoundExceptionCreates an input file stream to read from a file with the specified name.
If a security manager exists, its checkRead method is called with the name argument t to see if the application is allowed read access to the file. This may result in a security exception .
Parameter Description name the system dependent file name Throw:
If the file is not found.
Throw:
If a security manager exists, its checkRead method is called with the name argument t to see if the application is allowed read access to the file. This may result in a security exception .
public int available()throws IOExceptionReturn Value:
Returns the number of bytes that can be read from this file input stream without blocking.
Throw:
If an I/O error occurs.
Overrides:
available in class InputStream .
public void close()throws IOExceptionCloses this file input stream and releases any system resources associated with the stream.
Throw:
If an I/O error occurs.
Overrides:
close in class InputStream .
protected void finalize()throws IOExceptionThis finalize method ensures that the close method of this file input stream is called when there are no more references to it.
Throw:
If an I/O error occurs.
Overrides:
finalize in class Object .
public final FileDescriptor getFD()throws IOExceptionReturn Value:
Returns the file descriptor object associated with this stream.
Throw:
If an I/O error occurs.
public int read()throws IOExceptionReads a byte of data from this input stream. This method blocks if no input is yet available.
Return Value:
Returns the next byte of data, or -1 if the end of the file is reached.
Throw:
If an I/O error occurs.
Overrides:
read in class InputStream .
public int read(byte b[])throws IOExceptionReads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
Return Value:
Returns the total number of bytes read into the buffer, or -1 is there is no more data because the end of the file has been reached.
Parameter Description b the buffer into which the data is read Throw:
If an I/O error occurs.
Overrides:
read in class InputStream .
public int read(byte b[], int off, int len)throws IOExceptionReads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
Return Value:
Returns the total number of bytes read into the buffer, or -1 is there is no more data because the end of the file has been reached.
Parameter Description b the buffer into which the data is read off the start offset of the data len the maximum number of bytes read Throw:
If an I/O error occurs.
Overrides:
read in class InputStream .
public long skip(long n)throws IOExceptionSkips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly zero. The actual number of bytes skipped is returned.
Return Value:
Returns the actual number of bytes skipped.
Parameter Description n the number of bytes to be skipped Throw:
If an I/O error occurs.
Overrides:
skip in class InputStream .