import java.io.*;import javax.swing.*;import java.lang.*;import static javax.swing.JFrame.*;public class Main { public static void main(String args[]) { try { String t[] = { "小明,男,20", "小红,女,21", "小刚,男,29" }; FileWriter fr = new FileWriter("A.txt");//这里也可以用File来构造 BufferedWriter br = new BufferedWriter(fr);//利用FileReader来构造 for (String s : t) { br.write(s); br.newLine();//腐乳换行 } br.close(); fr.close(); FileReader fr1 = new FileReader("A.txt"); BufferedReader br1 = new BufferedReader(fr1); String s = br1.readLine(); while (s != null) { System.out.println(s); s = br1.readLine(); } br1.close(); fr1.close(); } catch (IOException e) { System.out.println(e.getMessage()); } }}