I'm working with file manipulation and I'm not able to compare what the user types with the password and login saved in the person's registration file! I can not get a specific position within .txt
public class Validacao {
public static Aluno validarlogin() throws IOException {
Aluno alu = new Aluno();
Scanner logusuario = new Scanner(System.in);
System.out.println("Digite seu nome completo: ");
alu.nome = logusuario.nextLine();
String nomearq = alu.nome + ".txt";
BufferedReader br = new BufferedReader(new FileReader(nomearq));
String linha = ";";
while ((linha = br.readLine()) != null ){
String[] vet = nomearq.split(";");
if(alu.login.equals(vet[1]) && alu.senha.equals(vet[2])){
System.out.println("Senha correta! ");
alu.login(vet[2]);
alu.senha(vet[3]);
}
}
return alu;
}
With this code I get this error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
But they should have 12 Strings in my .txt
At the time of saving the register I saved separating with ;
.
And the split()
was to pass the data from .txt
to ArrayList
was not?