FileWriter FileWriter(FileDescriptor) in Java

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

Syntax:

java.io.FileWriter.FileWriter(FileDescriptor fd)

This method takes one argument. This method constructs a FileWriter given a file descriptor, using the platform's default charset.

Parameters: One parameter is required for this method.

fd: the FileDescriptor to write.

Exceptions: NA

Approach

Java

import java.io.FileDescriptor;
import java.io.FileWriter;

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

        FileDescriptor fd = new FileDescriptor();
        FileWriter fileWriter = new FileWriter(fd);

        System.out.println(fileWriter);
    }
}

Output:

java.io.FileWriter@26f0a63f



Some other methods of FileWriter.

FileWriter(File)This method constructs a FileWriter given the File to write, using the platform's default charset.

FileWriter(String)This method constructs a FileWriter given a file name, using the platform's default charset.

FileWriter(File, boolean)This method constructs a FileWriter given the File to write and a boolean indicating whether to append the data written, using the platform's default charset.

FileWriter(File, Charset)This method constructs a FileWriter given the File to write and charset.

FileWriter(String, boolean)This method constructs a FileWriter given a file name and a boolean indicating whether to append the data written, using the platform's default charset.

FileWriter(String, Charset)This method constructs a FileWriter given a file name and charset.

FileWriter(String, Charset, boolean)This method constructs a FileWriter given a file name, charset, and a boolean indicating whether to append the data written.

FileWriter(File, Charset, boolean)This method constructs a FileWriter given the File to write, charset, and a boolean indicating whether to append the data written.


No comments:

Post a Comment