-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.java
54 lines (41 loc) · 1.15 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner; // Import the Scanner class
import java.util.ArrayList;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.net.*;
public class Main{
public static void main(String[] args){
ArrayList<countryStat> data = readFile();
}
/* readFile läser allt som finns i data.txt och
returnerar en arraylist<countryStat> */
public static ArrayList<countryStat> readFile(){
ArrayList<countryStat> all = new ArrayList<countryStat>();
try{
File file = new File("data.txt");
Scanner sc = new Scanner(file);
sc.nextLine();
String Name = "";
countryStat cs = new countryStat("blabla");
while(sc.hasNext()){
if(!Name.equals(cs.countryName)){
all.add(cs);
cs = new countryStat("blabla");
}
String s = sc.nextLine();
String t = "";
for(int i = 11; i<s.length();i++){
t = t + s.charAt(i);
}
String[] array = t.split(",");
Name= array[5];
System.out.println(2);
}
}catch (Exception e) {
System.out.println("fel: " + e);
}
System.out.println(all);
return all;
}
}