Optional lesson — beyond the AP CS A exam. Writing to files is not on the AP exam (which only reads files); this is here for a fuller picture of Java.
Writing to a text file
To write to a file, create a PrintWriter from a File (or file name), write with print/println, and always close() when done — closing flushes and saves the file. Opening a file for writing can fail, so the method declares throws IOException.