Ok, tell me if I am wrong, but here's how I would expect your original code to run:
ENTER WHILE (outer):
line = "item1 250"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item1"
price = 250.0
stuff[0] = new Inventory(item,price);
CONTINUE WHILE (inner):
item = tokenizer.nextToken() == NoSuchElementException
ENTER CATCH:
do nothing
CONTINUE WHILE (outer):
line = "item2 350"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item2"
price = 350.0
stuff[1] = new Inventory(item,price);
CONTINUE WHILE (inner):
item = tokenizer.nextToken() == NoSuchElementException
ENTER CATCH:
do nothing
CONTINUE WHILE (outer):
line = "item3 1050"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item3"
price = 1050.0
stuff[2] = new Inventory(item,price);
CONTINUE WHILE (inner):
item = tokenizer.nextToken() == NoSuchElementException
ENTER CATCH:
do nothing
CONTINUE WHILE (outer):
line = "item4"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item4"
price == NoSuchElementException
ENTER CATCH:
do nothing
CONTINUE WHILE (outer):
line = "item5 1610"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item5"
price = 1610.0
stuff[3] = new Inventory(item,price);
CONTINUE WHILE (inner):
item = tokenizer.nextToken() == NoSuchElementException
ENTER CATCH:
do nothing
CONTINUE WHILE (outer):
line = "item6 1505"
tokenizer = new StringTokenizer(line);
ENTER TRY:
ENTER WHILE (inner):
item = "item6"
price = 1505.0
stuff[4] = new Inventory(item,price);
CONTINUE WHILE (inner):
item = tokenizer.nextToken() == NoSuchElementException
ENTER CATCH:
do nothing
EXIT WHILE (outer)
Now, with the
while(true) loop, you would just be getting a ton of NoSuchElementExceptions since you would continue to try to tokenize past the end of the line. If I'm correctly, you probably wouldn't even notice, since you are catching those errors, but doing nothing when you do. What I mean by all of this is that the inner while loop (or any inner loop) is unnecessary in this situation (assuming you don't have more than one Inventory Item on each line).