Since we have a do-while loop, so after 45 is matched, we look for another match, no match is found so s.findInLine returns null. We display null and then check if nothing was found and then end the loop...
If you do the program as follows then you will not get null as output:
In this case, your while loop body will not be executed if the token is null. Actually, here the loop condition is test first and then print the output (execute the loop body) when condition is true, but, in your case the output is printed first (execute the loop body) then test the loop condition for the next iteration.
M.Sc. in CS, OCPJP6 93%
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com