Java Text file Output

  • try and catch statements are used to catch errors when writing to a file.
  • one Java classes are used in this example:
    • FileWriter: sets up a text file for writing
      • FileWriter methods used in the example: close() write()
Things to Notice:
  • the +"\r\n" is needed to place each line of text output on a new line in the file.

Sample Code: