package StudentPkg; /* * StudentFile.java * * Created on January 6, 2002 * This class facilitates reading students from a file. * * @author Stuart Hansen */ import java.util.*; import java.io.*; public class StudentDataFile{ Scanner in; public StudentDataFile (String fileName) { try { in = new Scanner(new File(fileName)); } catch (Exception e) { System.out.println ("Problem opening " + fileName); } } /** read a student from an easyfile **/ public Student readStudent () { String name = in.next(); int exam1 = in.nextInt(); int exam2 = in.nextInt(); int exam3 = in.nextInt(); return (new Student(name, exam1, exam2, exam3)); } /** returns true if there is more data to read */ public boolean hasNext() { return in.hasNext(); } }