FileWriter Class
Package: java.io
The FileWriter class connects to a File object and provides the basic ability to write to the file.
In most cases, you won’t use methods of this class directly. Instead, you’ll use this class to connect to BufferedWriter, which extends the FileWriter class by providing buffering for more efficient output. Then, you’ll connect the Buffered Writer object to a PrintWriter object, which has more useful methods for writing output data to a character stream. As a result, this section shows only the constructor for the FileWriter class and not its methods. For more information, see PrintWriter Class.
Constructors
|
Constructor |
Description |
|
|
Creates a file writer from a |
|
|
Creates a file writer from a |
The following example shows how to create a FileWriter object that appends to an existing file:
File f;
FileWriter fwriter;
f = new File(“myfile.txt”);
fwriter = new FileWriter(f, true);
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access