📜  Java.io.FileWriter类

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


介绍

Java.io.FileWriter类是用于编写字符文件的便捷类。以下是有关FileWriter的要点-

  • 此类的构造函数假定默认字符编码和默认字节缓冲区大小是可接受的。

  • FileWriter用于编写字符流。要写入原始字节流,请使用FileOutputStream

类声明

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

public class FileWriter
   extends OutputStreamWriter

领域

以下是Java.io.FileWriter类的字段-

  • protected Object lock-这是用于同步此流上的操作的对象。

类的构造函数

Sr.No. Constructor & Description
1

FileWriter(File file)

This constructs a FileWriter object given a File object.

2

FileWriter(File file, boolean append)

This constructs a FileWriter object given a File object.

3

FileWriter(FileDescriptor fd)

This constructs a FileWriter object associated with a file descriptor.

4

FileWriter(String fileName)

This constructs a FileWriter object given a file name.

5

FileWriter(String fileName, boolean append)

This constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.

类方法

此类从以下类继承方法-

  • Java.io.OutputStreamWriter
  • java.uti.Writer
  • Java对象