Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. private ArrayList<Earthquake> earthquakes = new ArrayList<Earthquake>();
  2. ArrayList<String> ans = new ArrayList<String>();
  3.  
  4.  
  5. public void loadData(){
  6. String filename = UIFileChooser.open("Data File");
  7. this.readAllLines(filename);
  8.  
  9. for (int i = 0; i < this.ans.size(); ++i) {
  10. String current = this.ans.get(i);
  11. try{
  12. Scanner scan = new Scanner(filename);
  13. while (scan.hasNext()){
  14. current.split(",");
  15.  
  16. }
  17. scan.close();
  18. return;
  19. }
  20. catch(IOException e){UI.println("File reading failed");}
  21. }
  22.  
  23. UI.printf("Loaded %d earthquakes into listn", this.earthquakes.size());
  24. UI.println("----------------------------");
  25. }
  26.  
  27. public ArrayList<String> readAllLines(String fname){
  28. ArrayList<String> ans = new ArrayList<String>();
  29. try {
  30. Scanner scan = new Scanner(new File(fname));
  31. while (scan.hasNext()){
  32. ans.add(scan.nextLine());
  33. }
  34. scan.close();
  35. return ans;
  36. }
  37. catch(IOException e){UI.println("File reading failed");}
  38. return null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement