I have to import a text file containing both words and integers and then maintain the data using a two dimensional array. I can't seem to figure out how to make this array. The only imports I can use are Scanner, File, and FileNotFoundException. Here is the snippet of my code:
public static void DisplayInventory() throws FileNotFoundException
{
try
{
Scanner autoInventory = new Scanner(new File("records.txt"));
for (int Num = 0; Num < 15; Num++)
{
String autoRecords = autoInventory.nextLine();
autoRecords = autoRecords.replace(';', ' ');
System.out.println(autoRecords);
}
}
catch (FileNotFoundException except)
{
System.out.println("Error: Inventory read failure. Error " +
except.getMessage());
System.exit(-1);
}
}
As you can see, this does not show an array. I am unsure how to do this and have been at this for a few days now. I am a novice at java and this is an assignment. I appreciate any help you can give.
records.txtfile?