I have broken down my code and reviewed it 1 by 1 to see this error and I am not sure of how to handle it, I'm trying to read multiple lines from file and store the data into Array. I'm able to store details[0] as Username but when I try adding details[1] and details[2] I get the error. Can someone help me please?
Data in the file:
test|9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08|500
testing|9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08|400
testtry|9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08|300
testnew|9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08|200
The code is below
Scanner read = new Scanner(new File("players.dat"));
String line;
ArrayList<String> players = new ArrayList<String>();
while (read.hasNextLine()){
line = read.nextLine();
String[] details = line.split("\\|");
String UserN = details[0];
String Password = details[1];
String Chips = details[2];