I'm fairly new to java and I'm a little stuck with how I can extract each string in a line from a file and then setting those in values in 6 different variables using Scanner. This is what I have so far:
File fileName = new File("studentInfo.txt");
Scanner file = new Scanner(fileName);
while(file.hasNext()){
String s = file.next();
System.out.println(s);
}
file.close();
studentInfo.txt
John Smith 1990 12 25 Junior
Jesse Jane 1993 10 22 Freshman
Jack Ripper 1989 01 14 Senior
My output, prints:
John
Smith
1990
12
25
Junior
So basically I need to set John to firstName, Smith to lastName, 1990 to year, 12 to month, 25 to day, and Junior to classYear, and then loop through the next line and so on. Can someone help? Thanks in advance.