2 import java
.io
.FileNotFoundException
;
3 import java
.util
.ArrayList
;
5 import java
.util
.Scanner
;
8 private String csvFile
= "data/countries.csv";
9 private String
[] continents
= {"Africa", "Americas", "Asia", "Europe", "Oceania"};
10 private ArrayList
<Country
> countryArrayListEurope
= new ArrayList
<>();
11 private ArrayList
<Country
> countryArrayListAfrica
= new ArrayList
<>();
12 private ArrayList
<Country
> countryArrayListAmericas
= new ArrayList
<>();
13 private ArrayList
<Country
> countryArrayListAsia
= new ArrayList
<>();
14 private ArrayList
<Country
> countryArrayListOceania
= new ArrayList
<>();
17 this.loadCSVCountries();
20 public String
[] getContinents() {
24 public ArrayList
<Country
> getCountryArrayListAfrica() {
25 return countryArrayListAfrica
;
28 public ArrayList
<Country
> getCountryArrayListAsia() {
29 return countryArrayListAsia
;
32 public ArrayList
<Country
> getCountryArrayListAmericas() {
33 return countryArrayListAmericas
;
36 public ArrayList
<Country
> getCountryArrayListEurope() {
37 return countryArrayListEurope
;
40 public ArrayList
<Country
> getCountryArrayListOceania() {
41 return countryArrayListOceania
;
44 public void loadCSVCountries() {
45 Scanner scanner
= null;
47 scanner
= new Scanner(new File(csvFile
));
48 } catch (FileNotFoundException e
) {
51 while (scanner
.hasNext()) {
52 List
<String
> line
= CSVUtils
.parseLine(scanner
.nextLine());
53 String countryList
= line
.get(0);
54 String
[] countryArray
= countryList
.split(",");
55 String latLng
= line
.get(16);
56 String
[] latLngArray
= latLng
.split(",");
57 if (line
.get(12).equals("Europe")) {
58 Country c
= new Country(countryArray
[1], line
.get(12), Double
.parseDouble(latLngArray
[0]), Double
.parseDouble(latLngArray
[1]), line
.get(21));
59 countryArrayListEurope
.add(c
);
60 } else if (line
.get(12).equals("Africa")) {
61 Country c
= new Country(countryArray
[1], line
.get(12), Double
.parseDouble(latLngArray
[0]), Double
.parseDouble(latLngArray
[1]), line
.get(21));
62 countryArrayListAfrica
.add(c
);
63 } else if (line
.get(12).equals("Americas")) {
64 Country c
= new Country(countryArray
[1], line
.get(12), Double
.parseDouble(latLngArray
[0]), Double
.parseDouble(latLngArray
[1]), line
.get(21));
65 countryArrayListAmericas
.add(c
);
66 } else if (line
.get(12).equals("Asia")) {
67 Country c
= new Country(countryArray
[1], line
.get(12), Double
.parseDouble(latLngArray
[0]), Double
.parseDouble(latLngArray
[1]), line
.get(21));
68 countryArrayListAsia
.add(c
);
69 } else if (line
.get(12).equals("Oceania")) {
70 Country c
= new Country(countryArray
[1], line
.get(12), Double
.parseDouble(latLngArray
[0]), Double
.parseDouble(latLngArray
[1]), line
.get(21));
71 countryArrayListOceania
.add(c
);
75 /*Utils.displayArrayList(countryArrayListOceania);
76 Utils.displayArrayList(countryArrayListAfrica);
77 Utils.displayArrayList(countryArrayListAmericas);
78 Utils.displayArrayList(countryArrayListAsia);
79 Utils.displayArrayList(countryArrayListEurope);*/