Write string array to a file with FileWriter in Java
Description
The following code shows how to write string array to a file with FileWriter.
Example
import java.io.FileWriter;
/*from w ww. j av a2 s .c o m*/
public class Main {
public static void main(String[] argv) throws Exception {
FileWriter fw = new FileWriter("myFile.txt");
String strs[] = { "com", "exe", "java2s.com" };
for (int i = 0; i < strs.length; i++) {
fw.write(strs[i] + "\n");
}
fw.close();
}
}