📜  Java.io.FileInputStream类

📅  最后修改于: 2020-11-15 02:42:16             🧑  作者: Mango


介绍

Java.io.FileInputStream类从文件系统中的文件获取输入字节。可用的文件取决于主机环境。以下是有关FileInputStream的要点-

  • 此类用于读取原始字节流,例如图像数据。

  • 要读取字符流,请使用FileReader

类声明

以下是Java.io.FileInputStream类的声明-

public class FileInputStream
   extends InputStream

类的构造函数

Sr.No. Constructor & Description
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.

类方法

Sr.No. Method & Description
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.io.InputStream
  • Java对象