I'm trying to make a program that reads in an external .txt file and manipulates it. The file has 5 different groups of data, 4 lines each (2 are int, 2 string). I need to read in the file using the Scanner class, Make an object to hold each group of data (write a class which stores the data group as a single object (lets call it ProgramData)). Then I need to create a ProgamData object and put that into an ArrayList, and repeat for each of the 5 groups.
I have a text file, and I read it in with the Scanner (I confirmed that I did this right through printing on the command line). I'm completely lost from there. Any help at all would be greatly appreciated.
Not like this will help, but here's my code so far:
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Project1
{
public static void main (String[] args) throws IOException
{
File dataFile = new File("C:\\Users/data.txt");
Scanner fileReader = new Scanner(dataFile);
int firstLine = fileReader.nextInt();
int secondLine = fileReader.nextInt();
String whiteSpace = fileReader.nextLine();
String thirdLine = fileReader.nextLine();
String fourthLine = fileReader.nextLine();
ArrayList<String> newArray = new ArrayList<String>();
}
}