I have a class "car", having five parametres of car (str brand, str model, str colour, int power, int tank), and I have a .txt with five cars, written like that:
Toyota Supra Black 280 80
Ferrari F430 Red 510 95
Nissan GT-R White 600 71
Koenigsegg Agera White 940 80
Mazda RX-8 Red 231 62
I have to read this list from file and make an array of lines array (cars), while each car array is an array of 5 parametres, like: Cars[car][parametres], and push it into a object of a class (should be a peace of cake, and i think i can handle this)
But i have no clue how to deal with array. Only thing i have now is reading from file:
void 123() {
String[] ImpData = null;
try {
String str;
BufferedReader br = new BufferedReader(new FileReader("imp.txt"));
while ((str = br.readLine()) != null) {
System.out.println(str);
}
br.close();
} catch (IOException exc) {
System.out.println("IO error!" + exc);
}
}
Any suggestions?
splitline on space.