Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void load(String filename) throws Exception {
- File file = new File(filename);
- if (!file.exists()) {
- System.out.println("The file '" + filename + "' does not exist");
- return;
- }
- Scanner fscan = new Scanner(file);
- for (int i=0; fscan.hasNext() == true; i++) {
- Person p = new Person();
- p.name = fscan.nextLine();
- p.address = fscan.nextLine();
- if (fscan.hasNextInt()) {
- p.age = fscan.nextInt();
- }
- if (fscan.hasNext()) {
- fscan.nextLine();
- }
- PersonList.add(i, p);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement