Sorry I still new to Java, basically my end result is asking input of a 'pin code' and that pincode will be inside the text document, but I don't sure how to even set them into arrays here below? Output of my arrays remain null instead of the text in the document. Also the catch is the one coming out.
The text document is placed in the same folder as the Java classes, should I make a full path?
There are only two items in the text,for example I want each to be in listArray[0] and listArray[1] respectively
if inside the document is literally:
1111,john doe,5000 /n*enter* 2222,glen johnson,4000
and i need the pin numbers in the left to be array[0] and for the names for be array[1]
this was an afterthought didnt think about having multiple accounts
Here is what I've tried so far:
public class Confirmation extends ATMrunner {
public static void pinConfirm() {
String[] listArray = new String[2];
try {
BufferedReader br = new BufferedReader(new FileReader("C:\Users\workspace\TellerMachine\src\bankATM\userlist.txt"));
String line = "";
while ((line = br.readLine()) != null) {
for (int i = 0; i <= 1; i++) {
listArray[i] = line;
}
}
br.close();
} catch (IOException ioe) {
System.out.println("File may be corrupted; please contact admin");
}
System.out.println(listArray[0]);
System.out.println(listArray[1]);
}
}
Appreciate some help!
IOException ioe? WHat message does it come with? Do you need to fully path the file?