I have a text file that looks like this,
John, 27, Kids, Married
Jane, 22, No Kids, Single
and so on...
I have read in the text file as seen below,
Scanner scan = new Scanner(System.in);
System.out.print ("Enter the name of the input file: ");
fileName = scan.nextLine();
fileScan = new Scanner(new File("in.dat"));
while (fileScan.hasNext())
{
fileName=fileScan.nextLine();
lineScan = new Scanner (fileName);
lineScan.useDelimiter(",");
String name=lineScan.next();
String team = lineScan.next();
int year = scan.nextInt();
String condition = lineScan.next();
double price = scan.nextInt();
What I am trying to do is figure out how I can scroll down through the text file and add each line to an array.
My Array would have i.e MyArray[] = (String name,String team,int year ,String condition ,double price )
I am totally confused on how to get that text file into an array...