My problem is the next: 1. I should get back 40 lines, but i get only 20. 2. The biggest problem is that i get back NULL for all lines. Why is that? What is the problem with the file reading?
Thanks in advance!
public class Program{
public static void main(String[] args) throws FileNotFoundException, IOException {
String[] egysor = new String[5];
String line;
FileReader fr = new FileReader("szavazatok.txt");
BufferedReader br = new BufferedReader(fr);
int n=0;
Sor[] sorok = new Sor[100];
while(br.readLine()!=null){
sorok[n] = new Sor();
egysor = br.readLine().split(" ");
sorok[n].setKorzet(egysor[0]);
sorok[n].setSzavazat(Integer.parseInt(egysor[1]));
sorok[n].setVezNev(egysor[2]);
sorok[n].setUtoNev(egysor[3]);
sorok[n].setPart(egysor[4]);
n++;
System.out.println(sorok[n]);
}
System.out.println(n);
and my class:
public class Sor {
private String korzet, vezNev, utoNev, part;
private int szavazat;`
public String getKorzet() {
return korzet;
}
public void setKorzet(String korzet) {
this.korzet = korzet;
}
public String getVezNev() {
return vezNev;
}
public void setVezNev(String vezNev) {
this.vezNev = vezNev;
}
public String getUtoNev() {
return utoNev;
}
public void setUtoNev(String utoNev) {
this.utoNev = utoNev;
}
public String getPart() {
return part;
}
public void setPart(String part) {
this.part = part;
}
public int getSzavazat() {
return szavazat;
}
public void setSzavazat(int szavazat) {
this.szavazat = szavazat;
}
public Sor(){
this.korzet = korzet;
this.vezNev = vezNev;
this.utoNev = utoNev;
this.part = part;
this.szavazat = szavazat;
}
public String toString(){
return "korzet"+korzet;
}