I have a txt that is something like this:
Jhon 113
Paul 024
David 094
Peter 085
and from each line i want to have 2 variables one of the type string for the name and one int for the number
I wrote this code and what it does its take what ever a line says and ands it to an array called names but i will like to khow how to split the line into two different variables.
import java.io.*;
public class Read {
public static void main(String[] args) throws Exception{
FileReader file = new FileReader("test.txt");
BufferedReader reader = new BufferedReader(file);
String names[] = new String[10];
for(int i = 0; i<names.length; i++){
String line = reader.readLine();
if(line != null){
names[i] = line;
}
}
}
}