The teacher passed an activity, which is for you to put the files in a txt, read, change and delete ... I am programming the search function, and it is not working. Could you help me?
public void searchUser(String login){
String result = "";
try {
FileReader fr = new FileReader("C:\Users\vanes\Documents\WEBprog\Archive\login.txt");
BufferedReader br = new BufferedReader(fr);
while (br.ready()) {
result += br.readLine() + "\n";
String divider[] = new String[2];//split
divider = result.split(";"); //split
if(divider[1].equals(login)){
System.out.println(divider[1]);
break;
}
}
br.close();
fr.close();
} catch (Exception ex) {
System.out.println("Erro");
}
}
This is the snippet of code. It should read line by line from login.txt, by splitting the split line into a vector's parameters, and comparing the input with one of those parameters that is already defined. It seems to me that he is not going through the other lines and is only reading the first one, when I "look" for the first line, it returns perfectly, the other does not ... why?