So the program I have is supposed to read from a file take that data (which is split into three parts divided by a space). These Strings need to be read and stored in an appropriate field. Now i dont know how to do this, I've tried with an array as you can see which i think is right but it only stores a single line. Someone told me that i should do that and then have spearate array objects or something? but i dont really know how. Help would be massivley appreciated.
import java.util.Scanner;
import java.io.*;
public class DataRead
{
private Scanner scan;
private String[]arraySplit = null;
public DataRead()
{
arraySplit = new String[100];
try
{
FileReader inputFile = new FileReader(//read file);
scan = new Scanner(inputFile);
}
catch (FileNotFoundException e)
{
System.out.println("FileNotFoundException - Could not find file");
}
catch (Exception e)
{
System.out.println("Unknown error");
}
while(scan.hasNext()) //reads through file while there is more to file
{
String line = scan.nextLine();
arraySplit = line.split(" ");
}
}