why
while((strLine = br.readLine()) != null)
reads the file 3 times ?
while((strLine = br.readLine()) != null)
reads the file 3 times ?
private List<String> getKlienci(){
try{
BufferedReader br = new BufferedReader(new FileReader("klienci.txt"));
String strLine ;
String nazwa;
String[] get_nazwa;
while((strLine = br.readLine()) != null) {
System.out.println(strLine);
get_nazwa=strLine.split(":");
if(get_nazwa[0].equals("nazwa")){ nazwa=get_nazwa[1];
klienci_z_pliku.add(nazwa); }
}
br.close();
}catch (FileNotFoundException e) {
System.err.println("File not found!");
}catch (IOException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace(); }
return klienci_z_pliku;
}
private List<String> getKlienci(){
try{
BufferedReader br = new BufferedReader(new FileReader("klienci.txt"));
String strLine ;
String nazwa;
String[] get_nazwa;
while((strLine = br.readLine()) != null) {
System.out.println(strLine);
get_nazwa=strLine.split(":");
if(get_nazwa[0].equals("nazwa")){ nazwa=get_nazwa[1];
klienci_z_pliku.add(nazwa); }
}
br.close();
}catch (FileNotFoundException e) {
System.err.println("File not found!");
}catch (IOException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace(); }
return klienci_z_pliku;
}
Comment