A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

import java.util.*;
import java.io.*;
public class TreeSetToFile {
        public static void main(String[] args)throws IOException {
                Scanner sc = new Scanner(System.in);
                Set<StudentScore> set = new TreeSet<StudentScore>(new ScoreComparator());
                for(int x = 0 ; x < 3 ; x++){
                        String line = sc.nextLine();
                        String[] str = line.split(" +");
                        set.add(new StudentScore(str[0], Integer.parseInt(str[1]),
                                        Integer.parseInt(str[2]), Integer.parseInt(str[3])));
                }
               
                BufferedWriter bfw = new BufferedWriter(new FileWriter("c:\\student.txt"));
                for(StudentScore s : set){
                        bfw.write(s.toString());
                        bfw.flush();
                        bfw.newLine();
                }
                bfw.close();
        }
}

4 个回复

倒序浏览
路过看一眼
回复 使用道具 举报
学生类的实现代码在呢?
回复 使用道具 举报
总结得很好
回复 使用道具 举报
风华正茂 来自手机 中级黑马 2015-8-23 12:24:01
报纸
楼主写得不错
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马