Syntax
- new BufferedWriter(Writer); //The default constructor
- BufferedWriter.write(int c); //Writes a single character
- BufferedWriter.write(String str); //Writes a string
- BufferedWriter.newLine(); //Writes a line separator
- BufferedWriter.close(); //Closes the BufferedWriter
- If you try to write from a
BufferedWriter
(using BufferedWriter.write()
) after closing the BufferedWriter
(using BufferedWriter.close()
), it will throw an IOException
.
- The
BufferedWriter(Writer)
constructor does NOT throw an IOException
. However, the FileWriter(File)
constructor throws a FileNotFoundException
, which extends IOException
. So catching IOException
will also catch FileNotFoundException
, there is never a need for a second catch statement unless you plan on doing something different with the FileNotFoundException
.