Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public static ArrayList<User> listOfCreatedUsers() throws IOException {
  2. ArrayList<User> listOfUsers = new ArrayList<>();
  3.  
  4. FileReader fr = new FileReader("src/userData.txt");
  5. BufferedReader bfr = new BufferedReader(fr);
  6. String line;
  7.  
  8. int totalLine = Destination.linesInFile("src/userData.txt"); //Bruger linesInFile metoden fra Destination class
  9.  
  10. for (int i = 0; i < totalLine; i++) {
  11. line = bfr.readLine();
  12. String[] strings = line.split("\\t", 6);
  13. User temp = new User();
  14.  
  15. temp.setFirstName(strings[0]);
  16. temp.setLastName(strings[1]);
  17. temp.setGender(strings[2]);
  18. temp.setAge(strings[3]);
  19. temp.setUsernameID(strings[4]);
  20. temp.setPassword(strings[5]);
  21.  
  22. listOfUsers.add(temp);
  23. }
  24. try {
  25. bfr.close();
  26. fr.close();
  27. } catch (IOException e) {
  28. e.printStackTrace();
  29. }
  30. return listOfUsers;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement