Most visited

Recently visited

Added in API level 1

FileWriter

public class FileWriter
extends OutputStreamWriter

java.lang.Object
   ↳ java.io.Writer
     ↳ java.io.OutputStreamWriter
       ↳ java.io.FileWriter


写字符文件的便利课程。 这个类的构造函数假定默认的字符编码和默认的字节缓冲区大小是可以接受的。 要自己指定这些值,请在FileOutputStream上构造一个OutputStreamWriter。

文件是否可用或可以创建取决于底层平台。 特别是,某些平台允许一次只打开一个文件,以便只写一个FileWriter (或其他文件写入对象)。 在这种情况下,如果涉及的文件已经打开,该类中的构造函数将失败。

FileWriter是为了写字符流。 要编写原始字节流,请考虑使用FileOutputStream

也可以看看:

Summary

Inherited fields

From class java.io.Writer

Public constructors

FileWriter(String fileName)

根据文件名构造一个FileWriter对象。

FileWriter(String fileName, boolean append)

给定一个文件名,用布尔值构造一个FileWriter对象,指示是否附加写入的数据。

FileWriter(File file)

给定一个File对象构造一个FileWriter对象。

FileWriter(File file, boolean append)

给定一个File对象构造一个FileWriter对象。

FileWriter(FileDescriptor fd)

构造与文件描述符关联的FileWriter对象。

Inherited methods

From class java.io.OutputStreamWriter
From class java.io.Writer
From class java.lang.Object
From interface java.lang.Appendable
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

Public constructors

FileWriter

Added in API level 1
FileWriter (String fileName)

根据文件名构造一个FileWriter对象。

Parameters
fileName String: String The system-dependent filename.
Throws
IOException if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

FileWriter

Added in API level 1
FileWriter (String fileName, 
                boolean append)

给定一个文件名,用布尔值构造一个FileWriter对象,指示是否附加写入的数据。

Parameters
fileName String: String The system-dependent filename.
append boolean: boolean if true, then data will be written to the end of the file rather than the beginning.
Throws
IOException if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

FileWriter

Added in API level 1
FileWriter (File file)

给定一个File对象构造一个FileWriter对象。

Parameters
file File: a File object to write to.
Throws
IOException if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

FileWriter

Added in API level 1
FileWriter (File file, 
                boolean append)

给定一个File对象构造一个FileWriter对象。 如果第二个参数是true ,那么字节将写入文件的末尾而不是开头。

Parameters
file File: a File object to write to
append boolean: if true, then bytes will be written to the end of the file rather than the beginning
Throws
IOException if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason

FileWriter

Added in API level 1
FileWriter (FileDescriptor fd)

构造与文件描述符关联的FileWriter对象。

Parameters
fd FileDescriptor: FileDescriptor object to write to.

Hooray!