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一下~

posted @ 2020-07-24 00:13  JC97  阅读(1213)  评论(0编辑  收藏  举报