JAVA中PrintWriter的用法
try (PrintWriter writer = new PrintWriter("student.txt")) { writer.println("姓名\t语文\t数学\t英语\t总分\t"); for (Student s : set) { writer.println(s.getName() + "\t" + s.getChinese() + "\t" + s.getMath() + "\t" + s.getEnglish() + "\t" + s.getTotalScore()); } } catch (IOException e) { e.printStackTrace(); }
今天学到了一种简便的输出输出流方法,mark一下~