| java.lang.Object | ||
| ↳ | java.io.InputStream | |
| ↳ | java.io.FileInputStream | |
Known Direct Subclasses
|
FileInputStream is a class for reading bytes from a file. This class may also be used with other InputStreams, ie: BufferedInputStream, to read data from a file with buffering.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new FileInputStream on the File
file. | |||||||||||
Constructs a new FileInputStream on the FileDescriptor
fd. | |||||||||||
Constructs a new FileInputStream on the file named
fileName. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns a int representing then number of bytes that are available before
this InputStream will block.
| |||||||||||
Close the FileInputStream.
| |||||||||||
Returns the FileChannel equivalent to this input stream.
| |||||||||||
Returns the FileDescriptor representing the operating system resource for
this FileInputStream.
| |||||||||||
Reads at most
count bytes from the FileInputStream and
stores them in byte array buffer starting at
offset. | |||||||||||
Reads bytes from the FileInputStream and stores them in byte array
buffer. | |||||||||||
Reads a single byte from this FileInputStream and returns the result as
an int.
| |||||||||||
Skips
count number of bytes in this FileInputStream. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This method ensures that all resources for this file are released when it
is about to be garbage collected.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.InputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
Constructs a new FileInputStream on the File file. If the
file does not exist, the FileNotFoundException is thrown.
| file | the File on which to stream reads. |
|---|
| FileNotFoundException | If the file is not found. |
|---|
Constructs a new FileInputStream on the FileDescriptor fd.
The file must already be open, therefore no
FileNotFoundException will be thrown.
| fd | the FileDescriptor on which to stream reads. |
|---|
Constructs a new FileInputStream on the file named fileName.
If the file does not exist, the FileNotFoundException is
thrown. The fileName may be absolute or relative to the
System property "user.dir".
| fileName | the file on which to stream reads. |
|---|
| FileNotFoundException | If the fileName is not found.
|
|---|
Returns a int representing then number of bytes that are available before this InputStream will block. This method always returns the size of the file minus the current position.
| IOException | If an error occurs in this stream. |
|---|
Close the FileInputStream.
| IOException | If an error occurs attempting to close this FileInputStream. |
|---|
Returns the FileChannel equivalent to this input stream.
The file channel is read-only and has an initial position within the file that is the same as the current position of the FileInputStream within the file. All changes made to the underlying file descriptor state via the channel are visible by the input stream and vice versa.
Returns the FileDescriptor representing the operating system resource for this FileInputStream.
| IOException | If an error occurs attempting to get the FileDescriptor of this FileInputStream. |
|---|
Reads at most count bytes from the FileInputStream and
stores them in byte array buffer starting at
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
| buffer | the byte array in which to store the read bytes. |
|---|---|
| offset | the offset in buffer to store the read bytes. |
| count | the maximum number of bytes to store in buffer. |
| IOException | If the stream is already closed or another IOException occurs. |
|---|
Reads bytes from the FileInputStream and stores them in byte array
buffer. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
| buffer | the byte array in which to store the read bytes. |
|---|
| IOException | If the stream is already closed or another IOException occurs. |
|---|
Reads a single byte from this FileInputStream and returns the result as an int. The low-order byte is returned or -1 of the end of stream was encountered.
| IOException | If the stream is already closed or another IOException occurs. |
|---|
Skips count number of bytes in this FileInputStream.
Subsequent read()'s will not return these bytes unless
reset() is used. This method may perform multiple reads to
read count bytes.
| count | the number of bytes to skip. |
|---|
| IOException | If the stream is already closed or another IOException occurs. |
|---|
This method ensures that all resources for this file are released when it is about to be garbage collected.
| IOException | If an error occurs attempting to finalize this FileInputStream. |
|---|