Skip to content

Most visited

Recently visited

navigation
Added in API level 1

FileWriter

public class FileWriter
extends OutputStreamWriter

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


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:

Summary

Inherited fields

From class java.io.Writer

Public constructors

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(String filename)

Creates a FileWriter using the platform dependent filename.

FileWriter(String filename, boolean append)

Creates a FileWriter using the platform dependent filename.

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 (File file)

Creates a FileWriter using the File file.

Parameters
file File: the non-null File to write bytes to.
Throws
IOException if file cannot be opened for writing.

FileWriter

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

Creates a FileWriter using the File file. The parameter append determines whether or not the file is opened and appended to or just opened and overwritten.

Parameters
file File: the non-null File to write bytes to.
append boolean: indicates whether or not to append to an existing file.
Throws
IOException if the file cannot be opened for writing.

FileWriter

Added in API level 1
FileWriter (FileDescriptor fd)

Creates a FileWriter using the existing FileDescriptor fd.

Parameters
fd FileDescriptor: the non-null FileDescriptor to write bytes to.

FileWriter

Added in API level 1
FileWriter (String filename)

Creates a FileWriter using the platform dependent filename.

Parameters
filename String: the non-null name of the file to write bytes to.
Throws
IOException if the file cannot be opened for writing.

FileWriter

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

Creates a FileWriter using the platform dependent filename. The parameter append determines whether or not the file is opened and appended to or just opened and overwritten.

Parameters
filename String: the non-null name of the file to write bytes to.
append boolean: indicates whether or not to append to an existing file.
Throws
IOException if the file cannot be opened for writing.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.