public class FileWriter extends OutputStreamWriter
是否可用或可能创建一个文件取决于底层平台。特别是一些平台,允许文件被打开,只有一个FileWriter写作(或其他文件的写作对象)在一个时间。在这种情况下,如果所涉及的文件已经打开,这个类的构造函数将失败。
FileWriter
是书写字符流。写作的原始字节流,考虑使用FileOutputStream
。
OutputStreamWriter
,
FileOutputStream
Constructor and Description |
---|
FileWriter(File file)
构建了一个文件对象FileWriter对象。
|
FileWriter(File file, boolean append)
构建了一个文件对象FileWriter对象。
|
FileWriter(FileDescriptor fd)
构建了一个文件描述符关联的FileWriter对象。
|
FileWriter(String fileName)
构造给定文件名的FileWriter对象。
|
FileWriter(String fileName, boolean append)
构造FileWriter对象给出一个文件名与一个布尔值,指示是否附加写入的数据。
|
close, flush, getEncoding, write, write, write
public FileWriter(String fileName) throws IOException
fileName
弦系统依赖的文件名。
IOException
-如果指定的文件存在但是目录而不是常规文件,不存在但不能被创造,也不能打开任何其他原因
public FileWriter(String fileName, boolean append) throws IOException
fileName
弦系统依赖的文件名。
true
append
布尔值,然后将数据写入到文件的末尾而不是开头。
IOException
-如果指定的文件存在但是目录而不是常规文件,不存在但不能被创造,也不能打开任何其他原因
public FileWriter(File file) throws IOException
file
-一个文件写入。
IOException
-如果文件存在,但是是一个目录而不是常规文件,不存在但不能被创造,也不能打开任何其他原因
public FileWriter(File file, boolean append) throws IOException
true
,然后字节将被写入到文件的末尾而不是开头。
file
-一个文件写入
append
-如果
true
,然后字节将被写入到文件的末尾而不是开头
IOException
-如果文件存在,但是是一个目录而不是常规文件,不存在但不能被创造,也不能打开任何其他原因
public FileWriter(FileDescriptor fd)
fd
- FileDescriptor对象写。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.