WriteChars

来源:互联网 发布:淘宝客服兼职可信吗 编辑:程序博客网 时间:2024/06/03 23:35
/** * Use FileWriter to write an array of storage to a file. */package FileIO;import java.io.*;/** * @author Administrator * */public class WriteChars {/** * @param args */public static void main(String[] args) {FileWriter fw;String strs[] = { "32435 Tom@HerbSchildt.com",  "86754 Mary@HerbSchildt.com",  "35789 TC@HerbSchildt.com" };try {// Open the output file.fw = new FileWriter("Employees.data");} catch (IOException exc) {System.out.println("Error Opening File");return ;}try {// Write the strings in strs to the file.for (int i = 0; i < strs.length; ++i) {fw.write(strs[i]); // write a line to filefw.write("\n");    // output a newline}} catch (IOException exc) {System.out.println("Error Writing File");}try {fw.close();} catch (IOException exc) {System.out.println("Error Closing File");}}}

0 0