Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I already realize that I would display them using a toString from my resource class, but I'm perplexed on how that would work. Don't get me wrong; I know how to make java read text/dat files, but I'm not to sure how to loop them after reading the file, and creating objects based off the file. Also how would I get the scanner to read a string and a number?

Here's what's in the text file:

cheese 12 12.50
sausage 15 21.89
peppers 10 15.05
pineapple 40 33.00
pepperoni 11 10.22
olive 9 8.99
xcheese 13 9.66
supreme 13 15.22
mushroom 17 16.34
bbqchicken 14 20.13
pepperoni 10 11.70
sausage 12 11.89
peppers 12 15.05
pineapple 14 13.50
squirrel 12 12.24
pickle 12 7.99
hawaiian 10 13.00
pepperoni 11 10.22
meat 13 9.66
sloppyJoe 15 15.30
dessert 14 17.60
bigBubba 16 25.00
steakLovers 23 30.77
bison 10 11.70
secretMeat 12 11.99
peppers 12 14.00
pineNeedle 13 13.50
sweetTart 12 12.24
tofu 7 8.99
Posted
Updated 4-Dec-14 20:55pm
v2

1 solution

there are plenty of resources available to refer in the internet. for example
Reading a text file line by line and storing an object in the array[^]
Reading a file line by line while storing an object in an array for each line[^]
Reading a text file in Java[^]
try to implement based on those and if you have issue ask question with your code and the problem details ( with error details if any)

Quote:
I know how to make java read text/dat files, but I'm not to sure how to loop them after reading the file, and creating objects based off the file. Also how would I get the scanner to read a string and a number?

Yes, refer the links and you can see how to use Scanner to read strings and numbers.
 
Share this answer
 
v2
Comments
TorstenH. 5-Dec-14 2:56am    
please post code and ask specfic, cause this is a typical homework task.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900