FileInputStream类的getFD()方法 (FileInputStream Class getFD() method)
getFD() method is available in java.io package.
getFD()方法在java.io包中可用。
getFD() method is used to return the FileDescriptor object that denotes the connection to the exact file in the file system being used by this FileInputStream.
getFD()方法用于返回FileDescriptor对象,该对象表示与此FileInputStream使用的文件系统中确切文件的连接。
getFD() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
getFD()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getFD() method does not throw an exception at the time of getting a file descriptor.
getFD()方法在获取文件描述符时不会引发异常。
Syntax:
句法:
public FileDescriptor getFD();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of the method is FileDescriptor, it returns the same FileDescriptor object linked with this stream.
该方法的返回类型为FileDescriptor ,它返回与此流链接在一起的相同FileDescriptor对象。
Example:
例:
// Java program to demonstrate the example
// of FileDescriptor getFD() method
// of FileInputStream
import java.io.*;
public class GetFDOfFIS {
public static void main(String[] args) throws Exception {
FileInputStream fis_stm = null;
FileDescriptor file_desc = null;
try {
// Instantiates FileInputStream
fis_stm = new FileInputStream("C:\\includehelp.txt");
// By using getFD() method is to return
// FileDescriptor linked with the stream
file_desc = fis_stm.getFD();
System.out.println("fis_stm.getFD(): " + file_desc);
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
// with the help of this block is to
// free all necessary resources linked
// with the stream
if (fis_stm != null) {
fis_stm.close();
}
}
}
}
Output
输出量
fis_stm.getFD(): [email protected]
翻译自: https://www.includehelp.com/java/fileinputstream-getfd-method-with-example.aspx