loading a text file
I am trying to load a text file which would look somthing like
Each line i am trying to get assigned to a particular variable, so John should be assigned to firstName.
I have started like
i know i will have to put it in a loop. But is there anyway i can say what line goes to what variable e.g
System.out.println("Please enter the name of the student file" );
String fileName = input.next();
in = new BufferedReader(new FileReader(fileName+".txt"));
firstName = in.readLine();
firstName = in.readLine(1);
lastName = in.readLine(2);
title = in.readLine(3);
Maybe you can try with a switch asking for the number of line that its been reading at the moment?
Something that's worked for me is the String split method using the new line character "\n" as my deliminator. But this was in a JTextArea, so it might not work.