My task is to: Pick 10 of my favourite NBA or NHL players from 2 top teams and display the player name, team name, points, rebounds, and assists for each of them. I then have to store this information as a table in a .txt file (This part is completed).
The number of points, rebounds, and assists for each team should be read from a .txt file and loaded into appropriately named arrays. The name of the file should be entered by the user.
Ok, so I have done my research and made the .txt file but I'm unsure of how to read from a .txt file and load the stats into appropriately named arrays...Any help is kindly appreciated thanks!
I have this much done so far...but I believe it's incorrect... :(
import java.io.*;
import java.util.Scanner;
class CPT {
public static void main ( String[] args )throws IOException {
File nameOfFile = new File("C:/myText.txt");
System.out.println("Now please enter the location of this text file!\nAn example would be: C:\\Users\\Your Name\\Desktop\\FolderWithTextFile\textfile.txt");
Scanner userInput = new Scanner(System.in);
String nameWithLocation = userInput.nextLine();
String stats[] = new String[10];
//creates a file object that will store the correct location of that file
File usersFile = new File(nameWithLocation);
}
}