|
@ -1,8 +1,8 @@ |
|
|
package org.example; |
|
|
package org.example; |
|
|
|
|
|
|
|
|
import java.io.BufferedWriter; |
|
|
|
|
|
import java.io.FileWriter; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Represents an student user in the system. |
|
|
* Represents an student user in the system. |
|
@ -75,5 +75,27 @@ public class Student { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static List<Student> readFromFile(String filename) |
|
|
|
|
|
{ |
|
|
|
|
|
List<Student> students = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(filename))) { |
|
|
|
|
|
String line; |
|
|
|
|
|
while ((line = reader.readLine()) != null) { |
|
|
|
|
|
String name = line; |
|
|
|
|
|
String id = reader.readLine(); |
|
|
|
|
|
String role = reader.readLine(); |
|
|
|
|
|
|
|
|
|
|
|
Student student = new Student(name, id, role); |
|
|
|
|
|
students.add(student); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return students; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |