11.3.4.1. PrintWriter.
Solution.
Because
FileWriter
contains a constructor that takes a file name argument, FileWriter(String)
, it can be used with PrintWriter
to perform output to a text file:PrintWriter outStream = // Create output stream
new PrintWriter(new FileWriter(fileName)); // Open file
outStream.print (display.getText()); // Print the text
outStream.close(); // Close output stream