<<< Unbuffered character file I/O | Index | Sequential output of ASCII files >>> |
Opening a file with a buffer
PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter("books.txt"));
Opening a file for an append operation
PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter("books.txt", true)));
Opening with autoflush feature turned on
PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter("books.txt")), true);
Note: Closing the output file is important:
out.close();
close() ensures that the buffer holding the output will be emptied -- all output generated by the program is sent to the output file.
<<< Unbuffered character file I/O | Index | Sequential output of ASCII files >>> |