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

© 李娟 黑马帝   /  2011-12-23 23:37  /  2190 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 李娟 于 2011-12-24 09:16 编辑

while((line=bufr.readLine())!=null)
                {
                        if("over".equals(line))
                                break;
                        String[] info = line.split(",");
                        String stu = new Student(info[0],Integer.parseInt(info[1]),
                                Integer.parseInt(info[2]),
                                Integer.parseInt(info[3]));
                        stus.add(stu);
                }
                bufr.close();
                return stus;
        }
        public static void write2File(Set<Student> stus)throws IOException
        {
                BufferedWriter bufw = new BufferedWriter(new FileWriter("stuinfo.txt"));
                for(Student stu:stus)
                {
                        bufw.write(stu.toString()+"\t");
                        bufw.write(stu.getSum()+"");
                        bufw.newLine();
                        bufw.flush();
                }
                bufw.close();
        }
}
class StudentInfoTest
{
        public static void main(String[] args) throws IOException
        {
                Comparator<Student> cmp = Collection.reverseOrder();
                Set<Student> stus = StudentInfoTool.getStudents();
                StudentInfoTool.write2File(stus);
        }
}

评分

参与人数 1技术分 +1 收起 理由
杨强 + 1

查看全部评分

2 个回复

正序浏览
  String stu = new Student(info[0],Integer.parseInt(info[1]),
这里用String去接收Student对象似乎有点不妥。你应该是把Strudent错写为String了。
找不到符号的原因,你看看有没有写错对象名,或者方法名。如果确定这两个都没错,那就再看看有没有导入运行时需要的包。应该是需要java.util.*;

评分

参与人数 1技术分 +1 收起 理由
杨强 + 1

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马