CSC216 Lab 01: Implement StudentRecordIO
StudentRecordIO
provides static
methods that support reading in student records from a file and writing student records to a file. A student record is defined in [Student Records Data Format]. The read functionality supports [Use Case 3: Load Student Directory] and the write functionality supports [Use Case 4: Save Student Directory].
The two required public methods for StudentRecordIO
are already provided as skeletons. If you provide any additional methods, like the private
one (private Student processStudent(String line)
) suggested in the design, they should be private
.
Since the methods of StudentRecordIO
are static
, StudentRecordIO
doesn’t require a defined constructor. There is a constructor listed in the design, but that is the default constructor that all classes have. You do NOT need to define a constructor for StudentRecordIO
. There is no state to initialize.
readStudentRecords(String)
Implementation
readStudentRecords(String fileName)
will read in Student
records from the file represented by the given fileName
. The records are returned in an ArrayList<Student>
in a very similar manner to CourseRecordIO.readCourseRecords()
from GP1. The method will throw a FileNotFoundException
if the file does not exist on the file system.
Conceptual Knowledge: Reading Hashed Strings
Student passwords are stored in a hashed string. The hashed string consists of characters with an underlying integer value between 0 and 255. The values between 0 and 127 are a determined set of characters from the standard alphabet and other control characters. The values between 128 and 255 are interpreted by different programs using different extended interpretations. The above link has some examples. To help keep things more consistent, we are using Base 64 encoding when hashing strings. This is done in StudentDirectory
.
Because we are working with character strings, using a File
parameter to the Scanner
object is not sufficient. The hashes are really bytes of data ,not a string you would read. So instead of using a File
parameter, you should instead use a FileInputStream
. FileInputStream
lets you read the input file as a series of bytes rather than a series of characters. After the Scanner
is created using the FileInputStream
, you can work with the Scanner
like you are used to.
You may assume that the password strings read in by StudentRecordIO
are already hashed. Passwords should NEVER be stored in plain text!
writeStudentRecords(String)
Implementation
writeStudentRecords(String fileName, ArrayList<Student> studentDirectory)
will write the Student
s in studentDirectory
to the file represented by the fileName
one Student
record at a time. The records are written in a very similar manner to CourseRecordIO.writeCourseRecords()
from GP1. The method will throw an IOException
if unable to write to the file.
Javadoc your Code
Make sure that you Javadoc the StudentRecordIO
class and methods.
Run CheckStyle to ensure that your Javadoc has all elements.
Reference: Staging and Pushing to GitHub
GitHub Resources:
Push to GitHub
Push your PackScheduler
project to GitHub
- Add the unstaged changes to the index.
- Commit and push changes. Remember to use a meaningful commit message describing how you have changed the code.
Reminder: Interpreting Jenkins
Check the following items on Jenkins for your last build and use the results to estimate your grade:
Check Jenkins
At this point your project will build on Jenkins, maybe even with a green ball! If you have test failures, use the feedback from Jenkins to help you resolve the issues. Make sure that all TS_StudentRecordIOTest
methods are passing before moving on to StudentDirectory
.