package javaapplication1;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class JavaApplication1 {
public static void main(String[] args) throws IOException {
String[] arr = new String[5];
arr[0] = "java";
arr[1] = "c";
arr[2] = "c++";
arr[3] = "c#";
arr[4] = "r2-d2";
try (BufferedWriter writer = new BufferedWriter(new FileWriter("d:\\data.txt"))) {
for (String s : arr) {
writer.write(s);
writer.newLine();
}
}
}
}
/* file: data.txt
java
c
c++
c#
r2-d2
*/
/*
run:
*/