Question: Write **TWO** programs. ********* PROGRAM 1: CreateBinaryUsingObjectStream.java (1) Read students.txt that contains students' information. Each student' info consists of two lines: name and classification. -
Write **TWO** programs. ********* PROGRAM 1: CreateBinaryUsingObjectStream.java (1) Read "students.txt" that contains students' information. Each student' info consists of two lines: name and classification. - Use a Scanner to read the text file. - Store each student's information in a Student object and then add the Student object in an array list of Student. (2) Create a binary file "studentsObjectStream.dat" using ObjectOutputStream. Write each student object as a whole to the binary file. Please do not write attribute by attribute. Note that you might have to make Student class Serializable. ********* PROGRAM 2: ReadBinaryUsingObjectStream.java It will read Student objects from the binary file created by Program 1 and print out the objects. The program should just rely on the toString method in Student.java). In order to earn full credits, the program shouldn't assume knowledge that there are six Student objects are in the file. If your program read exactly 6 Student object, you can still earn partial credits for Program 2.
public class Student { private String name; private int classification; public Student(String name, int classification) { this.name = name; this.classification = classification; } public String getName() { return name; } public int getClassification() { return classification; } @Override public String toString() { return String.format("Student: %s %d", name, classification); } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
