I have the the following input string:
1 imported box of chocolates at 10.00 1 imported bottle of perfume at 47.50
I would like to use the Java Scanner class to parse this input to create a list of product objects for example.
Please note the input line consists of multiple products (two in this case) as follows:
Quantity: 1
Name: imported box of chocolates
Price: 10.00
Quantity: 1
Name: imported bottle of perfume
Price: 47.50
Ideally I would like to parse the first product portion of the line and then the next product portion.
I know how to do this using regex etc but the question is:
What is the best way to use the Java Scanner to parse the input line?
Thank you.