March 21, 2020

Last time we talked about reading text files, today we're talking about writing text files.

Text files are the most simplest file to have. It's plain text. there's no fancy document things in it. No tables, no bolded elements, nothing. Just plain text.

So, how do we best write a text file? Like the following:


  public class WriteFile {

    public static void main(String[] args) {
      try {
        FileWriter myWriter = new FileWriter("myfile.txt");
        myWriter.write("Hello World!");
      } catch (IOException e) {
        System.out.println("An error occurred.");

Kyle Eggleston
Copyright © 2003 - 2020 archive