Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public void load(String filename) throws Exception {
  2. File file = new File(filename);
  3. if (!file.exists()) {
  4. System.out.println("The file '" + filename + "' does not exist");
  5. return;
  6. }
  7. Scanner fscan = new Scanner(file);
  8. for (int i=0; fscan.hasNext() == true; i++) {
  9. Person p = new Person();
  10. p.name = fscan.nextLine();
  11. p.address = fscan.nextLine();
  12. if (fscan.hasNextInt()) {
  13. p.age = fscan.nextInt();
  14. }
  15. if (fscan.hasNext()) {
  16. fscan.nextLine();
  17. }
  18. PersonList.add(i, p);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement