FileInputStream getFD() in Java

getFD(): This method is available in the java.io.FileInputStream class of Java.

Syntax:

FileDescriptor java.io.FileInputStream.getFD() throws IOException

This method returns the FileDescriptor object that represents the connection to the actual file in the file system being used by this FileInputStream.

Parameters: NA

Returns: the file descriptor object associated with this stream.

Throws:

IOException - if an I/O error occurs.

Approach

Java

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class FileInputStreamgetFD {

    public static void main(String[] args) throws IOException {

        String pathname = "D:\\hello.txt";
        File file = new File(pathname);
        FileInputStream fileInputStream =
new FileInputStream(file);

        System.out.println(fileInputStream.getFD());
        fileInputStream.close();
    }
}

Output:

java.io.FileDescriptor@182decdb


No comments:

Post a Comment