Lendo um arquivo e armazenando nomes e números em duas matrizes
Estou trabalhando em um programa que lê um arquivo e armazena os nomes e as pontuações em duas matrizes separadas, mas estou com dificuldades. É isso que eu tenho até agora. Criei uma matriz para nomes chamados nomes, mas estou confuso sobre como copiaria os nomes em cada índice da matriz.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ScannerReadFileSplit {
public static void main(String[] args) {
File file = new File("NamesScore.txt");
String[] names = new String[100];
int[] scores = new int[100];
int i;
try {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String [] words = line.split("\t");
for (String word: words) {
System.out.println(word);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Meu arquivo de texto é:
John James 60
Kim Parker 80
Peter Dull 70
Bruce Time 20
Steve Dam 90