Use FileWriter to write an array of strings to a file. : FileWriter « File « Java Tutorial






import java.io.FileWriter;

public class Main {
  public static void main(String[] argv) throws Exception {
    FileWriter fw = new FileWriter("file.dat");
    String strs[] = { "com", "exe", "doc" };

    for (int i = 0; i < strs.length; i++) {
      fw.write(strs[i] + "\n");
    }
    fw.close();
  }
}








11.33.FileWriter
11.33.1.FileWriter
11.33.2.Use FileWriter to write an array of strings to a file.
11.33.3.Append or add some contents to the file
11.33.4.Wrap FileWriter with BufferedWriter