Browse Source

documentation: readFromFile Method in Admin Class

remotes/origin/fdai7780
Tobias Herbert 11 months ago
parent
commit
0c9d4334f0
  1. 11
      src/main/java/org/example/Admin.java

11
src/main/java/org/example/Admin.java

@ -58,6 +58,11 @@ public class Admin {
System.out.println("Role: " + getRole());
}
/**
*
* @param admin the data of this admin is being written to the file
* @param filename the name of the file to write the data to
*/
public void writeToFile(Admin admin, String filename) throws IOException{
try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))){
String attributes = admin.getName() + "\n" + admin.getId() + "\n" + admin.getRole();
@ -65,6 +70,12 @@ public class Admin {
}
}
/**
*
* @param filename the name of the file to read the data from
* @return the list of admins that have been read from the file
*/
public static List<Admin> readFromFile(String filename)
{
List<Admin> admins = new ArrayList<>();

Loading…
Cancel
Save