FileReader FileReader(FileDescriptor) in Java

FileReader(FileDescriptor): This method is available in the java.io.FileReader class of Java.

Syntax:

java.io.FileReader.FileReader(FileDescriptor fd)

This method takes one argument. This method creates a new FileReader, given the FileDescriptor to read, using the platform's default charset.

Parameters: One parameter is required for this method.

fd: the FileDescriptor to read

Exceptions: NA

Approach

Java

import java.io.FileDescriptor;
import java.io.FileReader;

public class FileReader2 {
    public static void main(String[] args) {

        FileDescriptor fd = new FileDescriptor();
        FileReader fileReader = new FileReader(fd);

        System.out.println(fileReader);

    }
}

Output:

java.io.FileReader@7637f22


Some other methods of FileReader

FileReader(File)This method creates a new FileReader, given the File to read, using the platform's default charset.

FileReader(FileDescriptor)This method creates a new FileReader, given the FileDescriptor to read, using the platform's default charset.

FileReader(String)This method creates a new FileReader, given the name of the file to read, using the platform's default charset.

FileReader(File, Charset)This method creates a new FileReader, given the File to read and the charset.

FileReader(String, Charset)This method creates a new FileReader, given the name of the file to read and the charset.

No comments:

Post a Comment