Introduction to Java: input, output, file operations

I wrote a simple console application to show you how to read from and write to text files in Java. Basically it generates two HTML files (exam results based on a data file) in two formats. There is a version for students (results sorted by student id) and a version for a teacher (sorted by result). For Java programming I recommend IntelliJ IDEA.

A data file looks like this. First name then surname, student system id and number of points achieved. An example data file:

We want to store these lines in an array of objects so there is a class with variables needed, getters and setters and some more methods I will describe later. What’s important I use comparators (needed for sorting). I need data sorted by two keys so I use two comparators.

As you can see there is a few lines commented. If you need only one way of sorting you can uncomment them and comment those two comparators instead and use the following code somewhere in your StudentApp to do the sorting.

Continue reading Introduction to Java: input, output, file operations