The java.util.FileInputStream class obtains input bytes from a file in a file system. What files are available depends on the host environment.Following are the important points about FileInputStream:
This class is meant for reading streams of raw bytes such as image data.
For reading streams of characters, use FileReader.
類聲明
以下是聲明java.util.FileInputStream class:
public class FileInputStream extends InputStream
類構造方法
S.N. | 構造方法 & 詳細描述 |
---|---|
1 | FileInputStream(File file) This creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system. |
2 | FileInputStream(FileDescriptor fdObj) This creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system. |
3 | FileInputStream(String name) This creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system. |
類方法
S.N. | 方法 & 描述 |
---|---|
1 | int available() This method returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. |
2 | void close() This method closes this file input stream and releases any system resources associated with the stream. |
3 | protected void finalize() This method ensures that the close method of this file input stream is called when there are no more references to it. |
4 | FileChannel getChannel() This method returns the unique FileChannel object associated with this file input stream. |
5 | FileDescriptor getFD() This method returns the FileDescriptor object that represents the connection to the actual file in the file system being used by this FileInputStream. |
6 | int read() This method reads a byte of data from this input stream. |
7 | int read(byte[] b) This method reads up to b.length bytes of data from this input stream into an array of bytes. |
8 | int read(byte[] b, int off, int len) This method reads up to len bytes of data from this input stream into an array of bytes. |
9 | long skip(long n) This method skips over and discards n bytes of data from the input stream. |
方法繼承
此類從以下類繼承了上麵列出的方法
java.util.InputStream
java.util.Object