Im working on a login class, question about index
Hi,
Im working on a java login verfication class, i have a question regarding
a index system idea.
like instead of saying
words[4] i could say words[Password]
which would mean the first row in the persondata.txt would work as a index.
namelastnamessnSaleryPassword
and make it dynamic, if a "admin" would add a new "column" it would automaticaly work like
namelastnamessnSaleryPasswordnewdata
words[newdata]
import java.util.*;
import java.io.*;
publicclass Login{
publicstaticboolean validateUser (String inUsername, String inPassword)throws IOException, FileNotFoundException{
BufferedReader myIn =new BufferedReader(new FileReader("persondata.txt"));
BufferedReader read =new BufferedReader(new FileReader("persondata.txt"));// Tvungen o skapa en ny, out of boundexception=
String line ="";
String[] words;
String file =null;
int countLines = 0;
String username=null;
String password=null;
boolean confirm =false;
while((file = read.readLine()) !=null){
countLines ++;
}
for (int a=0; a<countLines; a++){
line = myIn.readLine();
words = line.split ("\\t+");
if(inUsername.equals(words[2]) && inPassword.equals(words[4])){// Fick vi in en tr鋐f? bra d?abbryter vi loopen
confirm =true;
break;
}
}
return confirm;// Retunerar true or false till servern
}
}
persondata.txt
BoEk650326-2781105abc123
NisseSvensson801202-122378,5aqw183
HassenKhameli790412-3423120jonas
LisaAndersson760203-343485kla12
JakobNilsson820603-444483sdlksq
EliziReveiro790923-125690lksfj
>

