Question: U Student.java question2 J Student.java students.txt X question1 1 Aaron 24 3 Edward 42 5 Heather 62 7 Jane 84 9 Linda 103 11 Zac



U Student.java question2 J Student.java students.txt X question1 1 Aaron 24 3 Edward 42 5 Heather 62 7 Jane 84 9 Linda 103 11 Zac 121 13 Stude Java E question 1 Write **TWO** programs. 2 3 ********* PROGRAM 1: CreateBinaryUsingObjectStream.java 4 5(1) Read "students.txt" that contains students' information. 6 Each student' info consists of two lines: name and classification. 7 8 - Use a Scanner to read the text file. 9 - Store each student's information in a Student object and then add the Student object in 10 an array list of Student. 11 12 (2) Create a binary file "studentsObjectStream.dat" using ObjectOutputStream. 13 14 Write each student object as a whole to the binary file. 15 Please do not write attribute by attribute. 16 17 Note that you might have to make Student class Serializable. 18 19 20 21 ********* PROGRAM 2: ReadBinaryUsingObjectStream.java 22 23 It will read Student objects from the binary file created by Program 1 24 and print out the objects. The program should just rely on 25 the toString method in Student.java). 26 27 In order to earn full credits, the program shouldn't assume knowledge 28 that there are six Student objects are in the file. 29 30 If your program read exactly 6 Student object, you can still earn partial 31 credits for Program 2. 1 package No2_binaryrousingObjectStream; 2 3 /* You may need to change the header of this class */ 4 5 public class Student { 6 private String name; 7 private int classification; 8 90 public Student(String name, int classification) { 10 this.name = name; 11 this.classification = classification; 12 } 13 140 public String getName() { 15 return name; 16 } 17 180 public int getClassification() { 19 return classification; 20 } 21 22e @Override 23 public String toString() { 24 return String.format("Student: %s %d", name, classification); 25 } 26 } 27
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
