I need to be able to verify a user inputted email and password against a csv file which I have that have to make sure that they are in the file and also that they match each other such as;
ojones@coldmail.net ocrabc. Currently I can split the file and print it to the screen but I cannot find a way to put it into an array which I can then refer to. Is there a better way of solving such a problem without an array?
import java.io.*;
import java.util.Arrays;
public class CSVRead{
public static void main(String[] arg) throws Exception {
BufferedReader CSVFile =
new BufferedReader(new FileReader("testa453.csv"));
String dataRow = CSVFile.readLine();
while (dataRow != null){
String[] dataArray = dataRow.split(",");
for (String item:dataArray) {
System.out.print(item + "\t");
}
System.out.println();
dataRow = CSVFile.readLine();
}
CSVFile.close();
System.out.println();
}
}
EDIT; Just to clarify I am reasonably new to Java and would like to use and array unless there is a more efficient way of solving the problem;
You can create a Map of e-mail -> password