Package java.io
Class FileWriter
java.lang.Object
java.io.Writer
java.io.OutputStreamWriter
java.io.FileWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class FileWriter extends OutputStreamWriter
A specialized
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.- See Also:
BufferedWriter,FileReader
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FileWriter(File file)Creates a FileWriter using the Filefile.FileWriter(FileDescriptor fd)Creates a FileWriter using the existing FileDescriptorfd.FileWriter(File file, boolean append)Creates a FileWriter using the Filefile.FileWriter(String filename)Creates a FileWriter using the platform dependentfilename.FileWriter(String filename, boolean append)Creates a FileWriter using the platform dependentfilename. -
Method Summary
Methods inherited from class java.io.OutputStreamWriter
close, flush, getEncoding, write, write, write
-
Constructor Details
-
FileWriter
Creates a FileWriter using the Filefile.- Parameters:
file- the non-null File to write bytes to.- Throws:
IOException- iffilecannot be opened for writing.
-
FileWriter
Creates a FileWriter using the Filefile. The parameterappenddetermines whether or not the file is opened and appended to or just opened and overwritten.- Parameters:
file- the non-null File to write bytes to.append- indicates whether or not to append to an existing file.- Throws:
IOException- if thefilecannot be opened for writing.
-
FileWriter
Creates a FileWriter using the existing FileDescriptorfd.- Parameters:
fd- the non-null FileDescriptor to write bytes to.
-
FileWriter
Creates a FileWriter using the platform dependentfilename.- Parameters:
filename- the non-null name of the file to write bytes to.- Throws:
IOException- if the file cannot be opened for writing.
-
FileWriter
Creates a FileWriter using the platform dependentfilename. The parameterappenddetermines whether or not the file is opened and appended to or just opened and overwritten.- Parameters:
filename- the non-null name of the file to write bytes to.append- indicates whether or not to append to an existing file.- Throws:
IOException- if thefilecannot be opened for writing.
-