I currently need to import data from a CSV file into an array as an object. The data is not all of the same type however and one line of the data is formatted like this "Tom, Jones, 95846, 657.45". I am able to parse the file but cannot seem to figure out how to store this data into an array. I will need to sort this data later on based on different requirements like Name and Number.
import java.io.*;
import java.util.*;
public class People {
public static void main(String[] args) {
File file = new File("People.csv");
People peopleArr[] = new People[100];
try{
Scanner inputFile = new Scanner(file);
inputFile.useDelimiter(",");
while(inputFile.hasNext()){
// Store the data into array
}
inputFile.close();
}catch (FileNotFoundException e){
System.out.println("Check file");
}
}
}