so after couples of days and reading on internet i found a working solution i want share
happy programming
import java.io.*;
import java.util.*;
public class huvudapp {
private String strID, strKM , strMIN ;
private int i;
public void lasFil()throws IOException{
Scanner sc = new Scanner (new File ("resor.txt")); //opens file named resor.txt
while (sc.hasNextLine()){ // the while is reading the file
String line = sc.nextLine(); // every line sends to "line" so we can split it
String [] arr = line.split(";"); //creats an array and says ";" when you see the symbol split the text
strID = arr[0]; // the diffrent values in the file get there names
int id = Integer.parseInt(strID);// string turns to INT for the IF statment
strKM = arr[1];
int km = Integer.parseInt(strKM);
strMIN = arr[2] ;
int min = Integer.parseInt(strMIN);
if (km>20 & min<60){
System.out.print("ID:"+id+" MIN:"+min+" KM:"+km +"\n"); // prints out the values that made the if statment
i++; // just to count how many persons there was.
}
}System.out.println(i+" persons that made the if statment");
}
public static void main(String[] args) throws IOException {
huvudapp mt = new huvudapp ();
mt.lasFil(); // calls the class ?? or object ? don't really know the definition
}
}
Prints
ID:1 MIN:38 KM:53
ID:2 MIN:27 KM:28
ID:5 MIN:35 KM:21
3 persons that made the if statment