
11.3 Reading and Writing Text Files 765
method, rather than appending a“\n”to our String, because the line separator
can be different on different platforms. This makes our code more portable. At
lines 24–29, we write three more lines of text and three more line separators.
At line 32, we call the close method to release the BufferedWriter resources.
Any further attempt to write to the file using the bw object reference will
result in an IOException being thrown (and caught at line 36). The catch
block at lines 36–39 uses an IOException as its parameter, which also
matches the type of exception thrown by the FileWriter constructor and the
write method. ...