public class FileWriter
extends java.io.OutputStreamWriter
Writer
that writes to a file in the file system. All
write requests made by calling methods in this class are directly forwarded
to the equivalent function of the underlying operating system. Since this may
induce some performance penalty, in particular if many small write requests
are made, a FileWriter is often wrapped by a BufferedWriter.BufferedWriter
,
FileReader
Constructor and Description |
---|
FileWriter(File file)
Creates a FileWriter using the File
file . |
FileWriter(File file,
boolean append)
Creates a FileWriter using the File
file . |
FileWriter(FileDescriptor fd)
Creates a FileWriter using the existing FileDescriptor
fd . |
FileWriter(java.lang.String filename)
Creates a FileWriter using the platform dependent
filename . |
FileWriter(java.lang.String filename,
boolean append)
Creates a FileWriter using the platform dependent
filename . |
public FileWriter(File file) throws java.io.IOException
file
.file
- the non-null File to write bytes to.java.io.IOException
- if file
cannot be opened for writing.public FileWriter(File file, boolean append) throws java.io.IOException
file
. The parameter
append
determines whether or not the file is opened and appended
to or just opened and overwritten.file
- the non-null File to write bytes to.append
- indicates whether or not to append to an existing file.java.io.IOException
- if the file
cannot be opened for writing.public FileWriter(FileDescriptor fd)
fd
.fd
- the non-null FileDescriptor to write bytes to.public FileWriter(java.lang.String filename) throws java.io.IOException
filename
.filename
- the non-null name of the file to write bytes to.java.io.IOException
- if the file cannot be opened for writing.public FileWriter(java.lang.String filename, boolean append) throws java.io.IOException
filename
. The
parameter append
determines whether or not the file is opened and
appended to or just opened and overwritten.filename
- the non-null name of the file to write bytes to.append
- indicates whether or not to append to an existing file.java.io.IOException
- if the file
cannot be opened for writing.